Skip to main content
Question

JWT - 404 As-User Call Fails When Making Enterprise API Calls

  • May 21, 2025
  • 1 reply
  • 2 views

Forum|alt.badge.img

So this is related to previous thread but I can't seem to make an enterprise api call using JWT.

 

It seems like As-User calls fails even if it's configured to allow it.

 

BOX_4w3hjmb6oie8vbrymg3tg9vem5vqf8yt.png

 

BoxDeveloperEditionAPIConnection api = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(
                ENTERPRISE_ID, CLIENT_ID, CLIENT_SECRET, encryptionPref, accessTokenCache);

        Date beginDate = new Date(System.currentTimeMillis() - (1000 * 60 * 60 * 2));
        Date endDate = new Date(System.currentTimeMillis());

        // Get enterprise events with enterprise api and not user api
        EventLog eventLog = EventLog.getEnterpriseEvents(api, beginDate, endDate);

        while (eventLog.getSize() > 0) {
             for (BoxEvent event : eventLog) {
                 if (event.getSourceJSON().get("item_id") != null) {
                     String itemId = event.getSourceJSON().get("item_id").asString();
                     String itemName = event.getSourceJSON().get("item_name").asString();

                     System.out.println("itemId: " + itemId);
                     System.out.println("itemName: " + itemName);

                     BoxFile boxFile = new BoxFile(api, itemId);
                     BoxFile.Info info = boxFile.getInfo();
                 }
             }
        }

Output:

itemName: downloads_dev08_advanced web dev with o365.pptx
com.box.sdk.BoxAPIException: The API returned an error code: 404

1 reply

Forum|alt.badge.img

I found by working with support that As-User is not yet supported in the box-java-sdk:

https://github.com/box/box-java-sdk/issues/76

 

So that's why it's not working.