Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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/download).
The problem is I am not being able to pass filenames containing international characters.
For example, I have a file "моя запись.txt" saved in my folder, with path "/моя запись.txt"
When I try to simply pass this string in the header, I get an error from ajax:
SyntaxError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '{"path":"/моя запись.txt"}' is not a valid HTTP header field value.
In V1 of API I simply encoded every path using encodeURIComponent function. In that case the path "/моя запись.txt" would become "%2F%D0%BC%D0%BE%D1%8F%20%D0%B7%D0%B0%D0%BF%D0%B8%D1%81%D1%8C.txt" and that worked for V1.
However, when I try the same with the V2, I get the following error from API:
Error in call to API function "files/download": HTTP header "Dropbox-API-Arg": path: '%2F%D0%BC%D0%BE%D1%8F%20%D0%B7%D0%B0%D0%BF%D0%B8%D1%81%D1%8C.txt' did not match pattern...
I tried to bypass this validation by keeping the slash and encoding only the file name itself. In this case the filepath becomes "/%D0%BC%D0%BE%D1%8F%20%D0%B7%D0%B0%D0%BF%D0%B8%D1%81%D1%8C.txt". This seems to be recognized as a valid path, but I get a new error:
"path/not_found/"
How do I correctly pass that path "/моя запись.txt" to the API endpoint?
Thank you,
Artem
Hi there!
If you need more help you can view your support options (expected response time for a 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!