1
votes

I have uploaded a file into my box account and now when I try to create a shared link for it using cURL, I am getting errors.

curl https://api.box.com/2.0/files/FILE_ID -H "Authorization: Bearer ACCESS_TOKEN" -d '{"shared_link": {"access": "open"}}' -X PUT

The error is as follows:

{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value '{shared_link:'. Entity body should be a correctly nested resource attribute name/value pair"}]},"help_url":"http://developers.box.com/docs/#errors","message":"Bad Request","request_id":"144849506852f47c 002e83b"}curl: (3) [globbing] unmatched brace at pos 9 curl: (3) [globbing] unmatched close brace/bracket at pos 5

Any thoughts or suggestions on what I am doing wrong?

1

1 Answers

1
votes

You are posting the JSON data using curl. So add this header to let the server know you are sending JSON.

-H "Content-Type: application/json"

Also, if you are using from windows, then use double quote(") around the JSON. For example

-d "{test:\"value\"}"

If you have problem with secure connection(https) then use this parameter as well.

-k