One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
jianwen
8 years agoExplorer | Level 3
HTTP API Path contain Chinese response 409 path not found?
I reply my question here:https://www.dropboxforum.com/t5/API-support/International-characters-in-filenames/m-p/175750#M6947
but not resolved,so i open a new post to illustate my issue:
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 send request to dropbox api,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/.
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.By the way,if there is no Chinese in path,response is success.
- Greg-DB
Dropbox Staff
If you're sending the same value as the SDK, please double check that you're connected to the same account/app. It's possible you're using an access token for a different account/app that in fact doesn't have anything at that path.
Otherwise, please share the full code we can use to reproduce the issue.- jianwenExplorer | Level 3
Account/app is correct, In the same folder for my test,i create two folders one path contains Chinese,one just pure English letters,the later folder test success,so the Account/APP is not the problem.
Here is the code https://gist.github.com/user20161119/84681489c04ef912d3646ab6ef05c357
Actually,just try to use httpclient to send the http request to dropbox api,will get the same result as mine.thanks
- jianwenExplorer | Level 3
Here is my code snippet,https://gist.github.com/user20161119/84681489c04ef912d3646ab6ef05c357
Actually,just try to use java httpclient to send to https://www.dropbox.com/developers/documentation/http/documentation#files-get_preview endpoint,will reproduce my issue,thanks
- Greg-DB
Dropbox Staff
Your code sample uses some custom classes so I can't run it, but this runs fine for me:
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; public class Main { public static void main(String[] args) throws IOException { String ACCESS_TOKEN = "<ACCESS_TOKEN>"; String filePath = "/blackdog/中文prd.docx"; JsonFactory jsonFactory = new JsonFactory(); OutputStream outputStream = new ByteArrayOutputStream(); JsonGenerator jsonGenerator = jsonFactory.createGenerator(outputStream); jsonGenerator.setHighestNonEscapedChar(0x7E); jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("path", filePath); jsonGenerator.writeEndObject(); jsonGenerator.close(); String arg = outputStream.toString(); System.out.println(arg); CloseableHttpClient httpclient = HttpClients.createDefault(); try { HttpPost httpost = new HttpPost("https://content.dropboxapi.com/2/files/get_preview"); httpost.setHeader("Authorization", "Bearer " + ACCESS_TOKEN); httpost.setHeader("Dropbox-API-Arg", arg); ResponseHandler<String> responseHandler = new ResponseHandler<String>() { @Override public String handleResponse(final HttpResponse response) throws IOException { int status = response.getStatusLine().getStatusCode(); System.out.println(status); HttpEntity entity = response.getEntity(); return entity != null ? EntityUtils.toString(entity) : null; } }; String responseBody = httpclient.execute(httpost, responseHandler); System.out.println(responseBody); } finally { httpclient.close(); } } }
That outputs:
{"path":"/blackdog/\u4E2D\u6587prd.docx"} 200 %PDF-1.4 %Çì¢ <more PDF content truncated for brevity>
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,945 PostsLatest Activity: 2 hours ago
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 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!