We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
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...
Greg-DB
7 years agoDropbox Staff
For these calls with the parameters in the header, you need to escape these characters. That is, when you use the “Dropbox-API-Arg” header, you need to make it “HTTP header safe”. This means using JSON-style “\uXXXX” escape codes for the character 0x7F and all non-ASCII characters.
Some, but not all, languages/libraries do this for you. For example, for JavaScript, to do this yourself you could do something like this:
var charsToEncode = /[\u007f-\uffff]/g;
function http_header_safe_json(v) {
return JSON.stringify(v).replace(charsToEncode,
function(c) {
return '\\u'+('000'+c.charCodeAt(0).toString(16)).slice(-4);
}
);
}
and then:
"Dropbox-API-Arg": http_header_safe_json(arg)
- wheel7 years agoExplorer | 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-DB7 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 ?
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!