Error renaming folder name via Update Folder using cURL
回答済みI am running the following command to rename a folder:
curl https://api.box.com/2.0/folders/FOLDER_ID -H "Authorization: Bearer MY_DEVELOPER_TOKEN" -d '{"name":"New_Folder_Name"}' -X PUT
But get the following error:
{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value ''{name:New_Folder_Name}''. 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":"rw8mnefrudnnzoqn"}
What am I missing?
-
I tried running the cURL command exactly as you have it there, and it seems to work just fine for me. The error you're seeing indicates that the JSON body of your request couldn't be parsed correctly (though the command you pasted looks fine to me, and works fine when I run it). Is there any way you can think of that the JSON might be getting malformed? Maybe something with the quotes, or missing characters (e.g. commas between properties, closing braces)?
-
double-quote is a special character in cURL, so if you want to pass a double-quote you must escape it with backslash. The box api documentation is misleading on the syntax to use for cURL. For example, here is how to rename a folder.
cURL https://api.box.com:443/2.0/folders/FOLDER_ID?fields=name -H "Authorization:Bearer ACCESS_TOKEN" -H "Content-Type: application/json" -d "{\"name\":\"NEW_FOLDER_NAME\"}" -X PUT
サインインしてコメントを残してください。
コメント
3件のコメント