Shared Link is always null

SOLVED
Go to solution
Highlighted
Occasional Contributor

Shared Link is always null

I am trying to create a shared link for a file that I uploaded using this curl command:

 

curl -X POST https://upload.box.com/api/2.0/files/content -H 'Authorization: Bearer <ACCESS_TOKEN>' -H "Content-Type: multipart/form-data" -F attributes='{"name":"kat_test.pdf","parent":{"id":"<FILE_ID>"},"shared_link":{"access":"open"}}' -F file=@test.pdf

 

The file is being uploaded with "shared_link" set to "null". Why?

 

Also I found SDK commands to create a shared link on a file but not a curl command. Our backend is in Go, so I am not able to use any of the existing SDKs. Is there a curl command I can run to create a shared link on file?

2 REPLIES 2
Highlighted
Box Employee

Re: Shared Link is always null

Hi @kliger,

 

The first thing that I would check on here is whether there are restrictions in the admin settings preventing shared links from being created. If someone with admin permissions goes to the content & sharing section of the admin console you should see something like the following:

 

sharing.png

 

Just make sure that the permissions set there will allow you to actually create shared links.

 

For the cURL command to generate a shared link, you'll want to call the update file endpoint (cURL command on the right side of the screen) and send in the shared link object as you did below.

 

Hope that helps,

Jon

Highlighted
Occasional Contributor

Re: Shared Link is always null

Thanks, @jcleblanc !

We found out that if we create a custom app with Oauth2+JWT authentication, it works.

Before we were using App Tokens, and that's when the API "fails silently" without creating a shared link.