Skip to main content

I am trying to create a shared link from a not root box folder by Java SDK using an enterprise account credential.



        log.info("Start createSharedLink. id: {}, canDownload: {}, canPreview: {}", id, canDownload, canPreview);

BoxFolder folder = new BoxFolder(boxProvider.getConnect(), id);

BoxSharedLinkRequest boxSharedLinkRequest = new BoxSharedLinkRequest()

.permissions(canDownload, canPreview)

.access(BoxSharedLink.Access.COLLABORATORS)

.unsharedDate(Date.valueOf(LocalDate.now().plusDays(3)));

BoxSharedLink sharedLink = folder.createSharedLink(boxSharedLinkRequest);

log.info("End createSharedLink. Created Url is: [{}]", sharedLink.getURL());



This request can work when I use either of following"


BoxSharedLink.Access.COMPANY


BoxSharedLink.Access.DEFAULT


BoxSharedLink.Access.OPEN



But only when I use COLLABORATORS, it will return me a 400 error



com.box.sdk.BoxAPIResponseException: The API returned an error code [400 | fuamn7hnyquow1er.03b4659d0dee504972e2e4896a16876e6] bad_request - Bad Request



There is no specific information here explained what I am missing.



Does anyone know what is wrong here or how to solve?

Hi @Noah , welcome to the forum.



The canDownload permission can only be used with the access set to OPEN or COMPANY, see here.



It is not possible to have a shared link with granularity for each individual collaborator.



Note that this only applies to shared links, individual collaborators can access the file normally via box.



Let us know if this helps.



Best regards


@rbarbosa thank you very much for checking my question.



I double check the document and tested, but even with given canDownload = false, it still throwing the same error.



Actually BOX support team just reply my same question raised there, if using COLLABORATORS, I should not specific any permissions, it will use the existing collaborators`s permission directly, I tested once and see it resolved.



As a conclusion, if use





  • BoxSharedLink.Access.COMPANY


  • BoxSharedLink.Access.DEFAULT


  • BoxSharedLink.Access.OPEN


    We will need to specific the permission(folder and file are different)




If use BoxSharedLink.Access.COLLABORATORS, we should not give any permission, or it will throw error.


Reply