Skip to main content
Question

BoxFolder.collaborate failed with 404 error

  • May 22, 2025
  • 2 replies
  • 24 views

Forum|alt.badge.img

Any Help with diagnose the error will be greatly appreciated!

Box Folder Collaborator API(BoxFolder.collaborate) failed with

“The API returned an error code [404 | xxx ] not_found - Not Found”

Description:

  1. I was able to manually add an external email as collaborator for this folder.
  2. Now I try to use Box API to add the same email as collaborator for the same folder, The Box API I am using is box box-java-sdk 2.58.0

public class BoxCollaborateTest {   

          public static final String BOX_CONFIG_FILE            = "BoxConfig.json";

          public static final String FOLDER_ID                 = "xxx";

          public static final String EMAIL                     = "xxxx";

          public static void main(String[] args) throws IOException {

                    Reader reader = new FileReader(BOX_CONFIG_FILE);

                    BoxConfig boxConfig = BoxConfig.readFrom(reader);

           BoxAPIConnection api = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(boxConfig);

                     BoxCollaborator user = new BoxUser(api, EMAIL);

                     BoxFolder folder = new BoxFolder(api, FOLDER_ID);

                     BoxCollaboration.Info collaborate = folder.collaborate(user, BoxCollaboration.Role.VIEWER );

                     System.out.println(collaborate.getID());

          }

}

3. the API failed with following error message.

Exception in thread "main" com.box.sdk.BoxAPIResponseException: The API returned an error code [404 | l00ctbgx3p2lzfht.0158df79cd2b75e1109a9af56c9278362] not_found - Not Found

        at com.box.sdk.BoxAPIResponse.<init>(BoxAPIResponse.java:94)

        at com.box.sdk.BoxJSONResponse.<init>(BoxJSONResponse.java:32)

        at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:731)

        at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:431)

        at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:398)

        at com.box.sdk.BoxCollaboration.create(BoxCollaboration.java:119)

        at com.box.sdk.BoxCollaboration.create(BoxCollaboration.java:69)

        at com.box.sdk.BoxFolder.collaborate(BoxFolder.java:217)

        at com.box.sdk.BoxFolder.collaborate(BoxFolder.java:143)

        at boxutils.BoxCollaborateTest.main(BoxCollaborateTest.java:30)

 

2 replies

Forum|alt.badge.img

Just want to clarify, I am using email  as userId here.

    public static final String EMAIL  = "xxx@gmail.com";
    ...
    BoxCollaborator user = new BoxUser(api, EMAIL);

I guess this may be the reason that it failed. If so, how should I create collaboration using email?


Forum|alt.badge.img

I figured out the problem and solution.

I used following code and the collaboration is successfully created:

 

BoxFolder folder = new BoxFolder(api, folderId);
BoxCollaboration.Info collaborate = folder.collaborate(email, BoxCollaboration.Role.VIEWER );