Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
wheel
8 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
Dropbox Community Moderator
8 years agoThe 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.
wheel
8 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.
- Greg-DB8 years ago
Dropbox Community Moderator
Can you share the actual complete code that reproduces this issue? It's hard to say what the problem might be from this description.
I do see that you're also escaping each " with a \. That may or may not be necessary, depending on the context in which you're doing this. I can't say without more information, but you may want to try removing those.
Also, in practice in recommend having a library build the JSON for you anyway, instead of manually constructing it.
- Sekali6 years agoExplorer | Level 4
when I create a okhttp request in andorid , I create json from gson。I request https://content.dropboxapi.com/2/files/upload
and submit param json like {"autorename":true,"mode":"add","mute":false,"path":"/\\u6d4b\\u8bd5.pdf","strict_conflict":false} . the Chinese char is encode Unicode . But I got a response below
upload result : {"error_summary": "path/malformed_path/", "error": {".tag": "path", "reason": {".tag": "malformed_path"}, "upload_session_id": "AAAAAAAAALgh7xt-gXMBJQ"}}
and I don't know what reason , please help me.
- Sekali6 years agoExplorer | Level 4
here is request code:
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, uploadfile);
Request request = new Request.Builder()
.url("https://content.dropboxapi.com/2/files/upload")
.method("POST", body)
.addHeader("Authorization", "Bearer "+token)
//"{\"path\": \"/w.pdf\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}"
.addHeader("Dropbox-API-Arg", requestJson)
.addHeader("Content-Type", "application/octet-stream")
.build();request json
{"autorename":true,"mode":"add","mute":false,"path":"/\\u6d4b\\u8bd5.pdf","strict_conflict":false}
when I request to upload file which named only contains English char ,it success. when it contains Chinese char ,it failed
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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!