Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
simotin13
2 years agoHelpful | Level 5
/files/download API fails
Hi,
I'm using Dropbox API and found /files/download API fails since few days before.
The API return following response body,
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Dropbox - 400</title>
<link href="https://cfl.dropboxstatic.com/static/metaserver/static/css/error.css" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" href="https://cfl.dropboxstatic.com/static/images/favicon.ico"/>
</head>
<body>
<div class="figure">
<img src="https://assets.dropbox.com/www/en-us/illustrations/spot/target-miss.svg" alt="Error: 400"/>
</div>
<div id="errorbox">
<h1>Error (400)</h1>Something went wrong. Don't worry, your files are still safe and the Dropbox team has been notified. Check out our <a href="https://status.dropbox.com">Status Page</a> to see if there is a known incident, our <a href="https://www.dropbox.com/help">Help Center</a> and <a href="https://forums.dropbox.com">forums</a> for help, or head back to <a href="https://www.dropbox.com/home">home</a>.
</div>
some APIs are still works successfully ex.(/get_metadata, /list_folder, /get_thumbnail), but '/files/download' fail.
Is there any information about this issue?
Thanks in advance simotin13
As Здравко mentioned, please make sure you're encoding header values as documented here: https://www.dropbox.com/developers/reference/json-encoding
13 Replies
Replies have been turned off for this discussion
- Greg-DB2 years ago
Dropbox Community Moderator
Nico-Uretek I don't actually see any encoding being done on your header values in your code. Please make sure you have the encoding implemented as covered here.
- Здравко2 years agoLegendary | Level 20
Nico-Uretek wrote:... Yes i'm using (french) accents and just the - characters in my name files and it would take a lot of time and devs to remove all of them...
No, no, this is not and cannot be an issue - it's not a surrogate pair! There is something else though:
Nico-Uretek wrote:...
String dbApiArg = '{\"path\": \"'+path+'/'+ a.name.replace('(xxx)','+') +'\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false}';...req.setHeader('Dropbox-API-Arg', dbApiArg);...Where is your string encoding above? 🤔 I cannot see it! That's what makes your issues. 😉
Hope this helps.
PS: Missing of any try for encoding (including for such symbols that have to be encoded not only according Dropbox, but mandatory according applicable standards) makes your code instable or even vulnerable - the JSON object may become restructured by just "appropriate" path/file!!!
- Nico-Uretek2 years agoHelpful | Level 5
Greg-DB Yes I still got the problems.
I'm using Dropbox on Salesforce and using two way to upload files (both didn't works since yesterday)- by using the official dropbox package "Dropbox for Salesforce" (apiName "Dropbox_for_SF") version 1.704
- by using a custom code in apex (like java) that create an http request on the
https://content.dropboxapi.com/2/files/upload with this code :HttpRequest req = new HttpRequest();req.setMethod('POST');String auth = 'Bearer '+tk;String content = 'application/octet-stream';String dbApiArg = '{\"path\": \"'+path+'/'+ a.name.replace('(xxx)','+') +'\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false}';Blob blobBodyValue = a.body;req.setHeader('Authorization', auth);req.setHeader('Content-Type', content);req.setHeader('Dropbox-API-Arg', dbApiArg);req.setBodyAsBlob(blobBodyValue);Http http = new Http();HTTPResponse res = http.send(req);The fact is that my code and the package was working since year and no modifications has been dones ! Other Api like list_folder or download still working. All my organization have this issue.I've test multiples times the upload api and without accents/special characters its work fine. But the management of the files is full automatised so we can't modify the file name to remove problematic characters.... - Здравко2 years agoLegendary | Level 20
Nico-Uretek wrote:..., Dropbox block now every special character and ... (not in accordance with the documentation haha). ...
Nico-Uretek, It depends on what you mean here. It's according Dropbox documentation, but NOT according standards. For instance, Dropbox (note the usage of Dropbox, not Dropbox API nor SDK) doesn't support all UNICODE symbols, but only those in Basic Multilingual Plane. 🤷 This is Dropbox core bug! Of course, the same results in impossible usage of surrogate pairs during JSON encoding - they are invalid according Dropbox API.
Do you use such symbols as file/folder names?
- Greg-DB2 years ago
Dropbox Community Moderator
Nico-Uretek If you're still seeing an issue when applying the encoding as documented, please share the specific steps, code, and parameter value(s) needed to reproduce the issue you're seeing so we can look into it. Be sure to redact any access/refresh tokens though. Thanks!
- Greg-DB2 years ago
Dropbox Community Moderator
Thanks for confirming simotin13!
- simotin132 years agoHelpful | Level 5
I checked link page about json-encoding.
I tried "HTTP-header-safe JSON" style and It certainly worked well.
Thank you for your support so quickly!
- Nico-Uretek2 years agoHelpful | Level 5
I'm correctly encoded.
I forgot to say that the API is used in an application in prod. I didnt modify the code since months.Thanks greg
- Greg-DB2 years ago
Dropbox Community Moderator
As Здравко mentioned, please make sure you're encoding header values as documented here: https://www.dropbox.com/developers/reference/json-encoding
- Здравко2 years agoLegendary | Level 20
simotin13 wrote:... --header "Dropbox-API-Arg: {\"path\":\"/aaa/あいうえお/sample.jpg\"}"
→ This request doesn't work. ...
Hi simotin13,
This for sure wouldn't work. Dropbox doesn't support modern JSON encoding (RFC-8259) with UTF-8 inside! Dropbox supports the old JSON tagging style encoding only - take a look here. Just use some encoding tool instead of encode JSON by hand - jq on the command line for instance.
Hope this gives direction.
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!