Skip to main content
Question

Preview Link Opens Window with Print and Download Buttons Disabled, Shared Link Returns a 403

  • May 22, 2025
  • 1 reply
  • 18 views

Forum|alt.badge.img
Hi All,
Is anyone else having these issues?
 
Creating a preview link with the API:
 
BoxAPIConnection api = new BoxAPIConnection(accessToken);
BoxFile file = new BoxFile(api, fileId);
URL url = file.getPreviewLink();
 
Results in an HTML page with the download and print buttons hidden:
BOX_809nzryz2cuexs3d2d7q2xnwyidk7u2s.png
 
Creating a shared link with the API:
 
BoxAPIConnection api = new BoxAPIConnection(accessToken);
BoxFile file = new BoxFile(api, fileId);
Permissions permissions = new Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);
String url = file.createSharedLink(Access.OPEN, null, permissions).getURL();
 
Results in:
 
com.box.sdk.BoxAPIException: The API returned an error code: 403
null
        at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:85) ~[box-java-sdk-2.8.2.jar:na]
        at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:477) ~[box-java-sdk-2.8.2.jar:na]
        at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:265) ~[box-java-sdk-2.8.2.jar:na]
        at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:240) ~[box-java-sdk-2.8.2.jar:na]
        at com.box.sdk.BoxFile.updateInfo(BoxFile.java:489) ~[box-java-sdk-2.8.2.jar:na]
        at com.box.sdk.BoxFile.createSharedLink(BoxFile.java:157) ~[box-java-sdk-2.8.2.jar:na]

1 reply

Forum|alt.badge.img

Hi , great question! 

 

For other readers, I believe I had 's support ticket and I wanted to repost my answer here for everyone else.

 

For the preview link, you're *very* close - in order to show the download and print buttons you need to append ?showDownload=true to the end of the URL. For example, if I have a preview link for a document at:

https://jpanent.app.box.com/preview/expiring_embed/...blahblahblah

You want to modify the URL to become

https://jpanent.app.box.com/preview/expiring_embed/...blahblahblah?showDownload=true

Reference:
https://developer.box.com/v2.0/reference#get-embed-link

I apologize that it's not called out in the SDK docs or in the "Getting Started" guide, either! I'll get a request in to quickly put in a sentence to make that more clear.

For the Shared Link, that's going to be expected behavior when using the New Box View. Just like the old View API, there's not really the concept of collaborations or permissions - all you can do with the New Box View (NBV for short) is upload, download, get preview link, and get converted assets (representations). This is called out in the blue section here:
https://developer.box.com/v2.0/docs/getting-started-with-new-box-view#section-overview

Although the Java SDK has way more endpoints documented, that's because it was built for the content API, which has everything you're more familiar with in Box - things like collaborations, metadata, shared links, etc. The New Box View is a pared-down subset of endpoints, which as a package, replaces the older View API.

Hope that explains it!

 

Thanks,

Jason