Skip to main content
Question

Update File Info using cUrl script

  • May 21, 2025
  • 12 replies
  • 54 views

Forum|alt.badge.img

Hello All,

 

I am trying to update a file (the description) using the following cUrl command :
curl https://api.box.com/2.0/files/file_id -H "Authorization: Bearer_Token" -D {"description":"New Description"} -X PUT -k

 

When I execute the command I am receiving the display of the current record. And no update is processed.

 

Can you please recommend the best approach.

 

Thanks.

12 replies

Forum|alt.badge.img

I was getting what you were seeing so I had to use a lower-case "-d" and add the single quotes around the description values.

 

curl -k https://api.box.com/2.0/files/> -H "Authorization: Bearer " -d '{"description":"New Description55"}' -X PUT


Forum|alt.badge.img

Hi @kendomen,

 

I tried your suggestion but I am receiving :

 

{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value ''{description:NewDefinition}''. 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":"***number removed for privacy***12369854df4963"}

 

Thanks.


Forum|alt.badge.img

Hello ,

 

you are missing the double quotes before and after the description and NewDefinition. Or better said you forgot the single quote that surrounds the body:

 

curl -k https://api.box.com/2.0/files/> -X PUT -H "Authorization:Bearer XXX" -H "Content-Type:application/json" -d '{"description":"NewDefinition"}'

 

It should be '{"description":"NewDefinition"}'

 

Regards


Forum|alt.badge.img

@LoCortes, ,

 

I tried the below cURL command (-d, -D, with/without the simple ) but none of them is triggering an update. The -d option is not working.  I am executing them from a  DOS prompt.

 

1 - Script=
curl https://api.box.com/2.0/files/file_id -H "Content-Type: text" -H "Authorization: Bearer Bearer_Token" -D {"description":"TestPOCNew"} -X PUT -k
1- Response=
{"type":"file","id":"file_id","file_version":{"type":"file_version","id":"***number removed for privacy***999","sha1":"***number removed for privacy***99999999999999999999999999999"},"sequence_id":"32","etag":"32","sha1":"***number removed for privacy***99999999999999999999999999999","name":"image.tif","description":"Actual Description","size":672708,"path_collection":{"total_count":3,"entries":[{"type":"folder","id":"0","sequence_id":null,"etag":null,"name":"All Files"},{"type":"folder","id":"***number removed for privacy***99","sequence_id":"2","etag":"2","name":"XXXXXXX DX"},{"type":"folder","id":"***number removed for privacy***99","sequence_id":"1","etag":"1","name":"XXXXXX META"}]},"created_at":"2017-03-24T13:36:19-07:00","modified_at":"2017-04-26T12:54:34-07:00","trashed_at":null,"purged_at":null,"content_created_at":"2017-03-01T05:59:08-08:00","content_modified_at":"2017-03-01T05:59:08-08:00","created_by":{"type":"user","id":"9999999","name":"John Woo","login":"***email address removed for privacy***"},"modified_by":{"type":"user","id":"4798076","name":"John Woo","login":"***email address removed for privacy***"},"owned_by":{"type":"user","id":"99999999","name":"Jean Jones","login":"***email address removed for privacy***"},"shared_link":null,"parent":{"type":"folder","id":"***number removed for privacy***99","sequence_id":"1","etag":"1","name":"XXXXXXX META"},"item_status":"active"}

 

2 -Script=
curl https://api.box.com/2.0/files/file_id -H "Content-Type: text" -H "Authorization: Bearer Bearer_Token" -D '{"description":"TestPOCNew"}' -X PUT -k
2- Response=
{"type":"file","id":"file_id","file_version":{"type":"file_version","id":"***number removed for privacy***999","sha1":"***number removed for privacy***99999999999999999999999999999"},"sequence_id":"32","etag":"32","sha1":"***number removed for privacy***99999999999999999999999999999","name":"image.tif","description":"Actual Description","size":672708,"path_collection":{"total_count":3,"entries":[{"type":"folder","id":"0","sequence_id":null,"etag":null,"name":"All Files"},{"type":"folder","id":"***number removed for privacy***99","sequence_id":"2","etag":"2","name":"XXXXXXX DX"},{"type":"folder","id":"***number removed for privacy***99","sequence_id":"1","etag":"1","name":"XXXXXX META"}]},"created_at":"2017-03-24T13:36:19-07:00","modified_at":"2017-04-26T12:54:34-07:00","trashed_at":null,"purged_at":null,"content_created_at":"2017-03-01T05:59:08-08:00","content_modified_at":"2017-03-01T05:59:08-08:00","created_by":{"type":"user","id":"9999999","name":"John Woo","login":"***email address removed for privacy***"},"modified_by":{"type":"user","id":"4798076","name":"John Woo","login":"***email address removed for privacy***"},"owned_by":{"type":"user","id":"99999999","name":"Jean Jones","login":"***email address removed for privacy***"},"shared_link":null,"parent":{"type":"folder","id":"***number removed for privacy***99","sequence_id":"1","etag":"1","name":"XXXXXXX META"},"item_status":"active"}

 

3 - Script =
curl https://api.box.com/2.0/files/file_id -H "Content-Type: text" -H "Authorization: Bearer Bearer_Token" -d '{"description":"TestPOCNew"}' -X PUT -k
3- Response=
{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value ''{description:TestPOCNew}''. 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":"***number removed for privacy***659023c5ded714"}

 

4- Script=
curl https://api.box.com/2.0/files/file_id -H "Content-Type: text" -H "Authorization: Bearer Bearer_Token" -d {"description":"TestPOCNew"} -X PUT -k
4 - Response=
{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value '{description:TestPOCNew}'. 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":"***card # removed for privacy***c70e5266"}

 

Thanks.


Forum|alt.badge.img

I am wondering if the API works of if I missing something ?

 

Thanks for your help.


Forum|alt.badge.img

Hello ,

 

the content type must be application/json and you are passing text.

 

Take this as it is and only change the ID and the token. Do not change the order of any parameters or anything else apart of the and the XXX: 

 

curl -k https://api.box.com/2.0/files/> -X PUT -H "Authorization:Bearer XXX" -H "Content-Type:application/json" -d '{"description":"NewDefinition"}'

 

Good luck.


Forum|alt.badge.img

Hello @LoCortes,

 

I followed your sugggestion. I took the query and only changed the ID () and the token (XXX). I did not change the parameters order. But I am receiving the follwing message:

 

 

{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value ''{description:NewDefinition}''. 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":"***number removed for privacy***8590342c62f7cd"}

 

Thanks.


Forum|alt.badge.img

I found a workaround.


Forum|alt.badge.img

What was the work around? Can you please your solution


Forum|alt.badge.img

What was the workaround?


Forum|alt.badge.img

Could you please share the solution/workaround?


Forum|alt.badge.img