Update File Info API not working
AnsweredHello,
I am looking to update the description of a file.
I am testing the following command (via PostMan):
The status is 200 Ok but the display is not showing any change in the description. It looks like the command is not updating the description field.
Can you plase suggest.
Thanks, ZZ
-
Hello ,
to update the description you have to use the PUT method not GET that I think is what you are using. Please look at here https://docs.box.com/v2.0/reference#update-a-files-information exactly how to do it.
You need to call a PUT method and send a json with the values.
Thanks
-
Hello!
could you enclose a screenshot please? I said the PUT thing because I see that the URL you shared is built as if it was a GET 🙂
I have done a test with Restlet Client that is similar to POSTMAN and works fine for me. See the screenshot.
You should have something similar.
Thanks
-
In your request, you have to send the updated values of name and description as body parameters. You also have to send the access token as a header in your request.
Here is a cURL example for this request:
curl https://api.box.com/2.0/files/FILE_ID \ -H "Authorization: Bearer ACCESS_TOKEN" \ -d '{"name":"newName", "description":"newDescription"}' \ -X PUT
Here is an example of this same request in Postman:
Since you are using Postman, I would suggest checking out our Postman collection that has most of the Box API calls already setup.
-
hello,
exactly. Probably I did not express myself clear enough, apologies.
But, you are doing the query as if the request was a GET one. As my screenshot shows the body is there.
If you do not pass anything on the body you have an OK because nothing has changed so the update is succesful.
Regards
-
Thanks for the update.
I tried the cURL example you provided but I see no update when I execute it. The current record is displayed with no updates on the name and decription columns.
Below the command I tried:
curl https://api.box.com/2.0/files/FILE_ID -H "Authorization: Bearer ACCESS-TOKEN" \
-D {"name":"NewName", "description":"NewDescription"} \
-X PUT -k
Any explanation would be appreciated. Thanks.
-
Hello @LoCortes,
Actually I was trying to understand explanation and the cURL example:
curl https://api.box.com/2.0/files/FILE_ID \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"name":"newName", "description":"newDescription"}' \
-X PUTI tried it and it didn't work.
I opened a separate discussion.
Thanks.
-
Hello,
I would try to finish the postman approach you were doing as it is easier 🙂
It does not work but could you share some screenshot or message or something? it will be easier to help you.
By the way, are you executing that exactly message that Murtza gave you? I guess you've changed the File_ID to some specific one and using your developer token, aren't you?
Thanks
Please sign in to leave a comment.
Comments
13 comments