0

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 \ 
file=@package.json -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"}

Tom Wu
  • 24
  • 4
  • 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. – Tom Wu Mar 27 '15 at 07:57

1 Answers1

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.

Greg
  • 3,731
  • 1
  • 29
  • 25