Your workflow is unique đšâđ» - tell us how you use Dropbox here.
Forum Discussion
Artem K.
9 years agoNew member | Level 1
International characters in filenames
Hi,
I am migrating to V2 of REST API and I am having problems with endpoints that require passing arguments using "Dropbox-API-Arg" header (for example, https://content.dropboxapi.com/2/files/downl...
Greg-DB
Dropbox Community Moderator
9 years agoHi Artem, as you saw in the API Explorer, 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 something like:
'Dropbox-API-Arg': http_header_safe_json({ path: dropboxFilePath })jianwen
8 years agoExplorer | Level 3
There is Chinese in path likeïŒ"/blackdog/äžæprd.docxâïŒi see the api explore send Dropbox-API-Arg as follow:
Dropbox-API-Arg:{"path":"/blackdog/\u4e2d\u6587prd.docx"}I am using java to implement http,my Dropbox-API-Arg as follow:
"Dropbox-API-Arg: {"path":"/blackdog/\\u4E2D\\u6587prd.docx"}"In java \\ standard for one \,and dropbox response as follow:
path/not_found/.
How could i resolve the issue?
- Greg-DB8 years ago
Dropbox Community Moderator
This may depend on your setup, but are you sure you need the double '/'? Have you tried it without it? i.e.,
"Dropbox-API-Arg: {"path":"/blackdog/\u4e2d\u6587prd.docx"}"In any case, we recommend either using the official Dropbox Java SDK, or having a library do the encoding for you. E.g., for Java, using Jackson, it would look like:
JsonFactory f = ... JsonGenerator g = f.createGenerator(...); g.setHighestNonEscapedChar(0x7E);
- jianwen8 years agoExplorer | Level 3
Actually i use Jackson format json as follow:
String path = "/blackdog/äžæPRD.docx"; path = StringEscapeUtils.escapeJava(path); path_req.setPath(path); String header_json = JsonUtils.writeValue(path_req); LoggerUtils.logInfo(this.getClass(), header_json);In java double / standards /,so following code
"Dropbox-API-Arg: {"path":"/blackdog/\u4e2d\u6587prd.docx"}"is correct in Java.
- jianwen8 years agoExplorer | Level 3
I debuged Dropbox java sdk,and the header Dropbox-API-Arg value is the same as mine
"Dropbox-API-Arg: {"path":"/blackdog/\\u4E2D\\u6587prd.docx"}[\r][\n]"but i got 409 path/not_found/..,dropbox sdk get right response,i don not why.
- Greg-DB8 years ago
Dropbox Community Moderator
It looks like you opened a new thread for this, so we'll follow up there:
https://www.dropboxforum.com/t5/API-support/HTTP-API-Path-contain-Chinese-response-409-path-not-found/m-p/240031#M13346
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!