1

I want the user to upload to our server and have our server then upload the file to a specific folder in Box using the API. How can I do this? What credentials should I use?

curl https://app.box.com/api/oauth2/token \
-d 'grant_type=client_credentials&client_id=CLIENT_ID&client_secret=SECRET'

returns

{"access_token":"TOKEN","expires_in":3793,"restricted_to":[],"token_type":"bearer"}

curl https://upload.box.com/api/2.0/files/content   \
-H "Authorization: Bearer TOKEN" -X POST  -F \ 
[email protected] -F folder_id=3306197480

returns

{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"parent","message":"Invalid value 'd_3306197480'. 'parent' with value 'd_3306197480' not found"}]},"help_url":"http://developers.box.com/docs/#errors","message":"Not Found","request_id":"1157604954550c7c754b9c9"}

1
  • Had to get an access token and refresh token as a user with access to the folder. Then I had to store those tokens on the server and periodically refresh the access token. Commented Mar 27, 2015 at 7:57

1 Answer 1

4

It sounds like the API is returning a 404 because the user associated with the access token doesn't have permissions to see the folder you're uploading to. Your server will need to authenticate as a user that is collaborated on that folder instead of authenticating as the user uploading the file.

Sign up to request clarification or add additional context in comments.

1 Comment

oh my god yes! added the app user as a collaborator and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.