You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
wheel
7 years agoExplorer | Level 4
Response headers
when i use dropbox api for uploading file. the http header contain chinese, for example:
"Dropbox-API-Arg:{\"path\": \"/Test/中文.doc\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"stric...
wheel
Explorer | Level 4
Thanks for replying.
I use dropbox api with winhttp and c.
Now, i'm trying to encode chinese to unicode. For example:
"工作.doc" --> "\u5de5\u4f5c.doc" ,
and the header is :
Dropbox-API-Arg:{\"path\": \"/Test/\u5de5\u4f5c.doc\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}.
But it also response error message:
Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input as JSON.
So, if i want to create the filename with chinese, what format should i input to header?
Greg-DB
7 years agoDropbox Staff
It looks like you're properly escaping the Unicode characters, but you have an extra period at the end of the string, making it invalid JSON. Remove that extra "." and try again.
- wheel7 years agoExplorer | Level 4
thanks for replying.
the " . " it actualy not at the end of the string , i accidentally added it in the api-arg.
i tryed to solve it by other ways.
in addition , what formats for path in dropbox-api header? utf-8? or unicode ?
- Greg-DB7 years agoDropbox Staff
The value sent in the header should be all ASCII, with JSON-style “\uXXXX” escape codes for the character 0x7F and all non-ASCII characters. The last sample you shared is correct, except for that period.
The path format itself is the same as elsewhere in the API. That is, non-root paths should start with "/" and also use "/" as the path component delimiter.
If something still isn't working as expected, please share some code that reproduces the issue so we can investigate.
- wheel7 years agoExplorer | Level 4
i add the header by the winapi WinHttpAddRequestHeaders.
and then,if the header as follows:
Dropbox-API-Arg:{\"path\": \"/Test/中文\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false} Content-Type: application/octet-stream Authorization: Bearer < token >
my ide is vs2017, i put these string in the array . and i use the function MultiByteToWideChar() encode the header to LPCWSTR. it will response error message.
in other words, if the path contain Chinese characters, it will response errror message.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 3 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!