Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
terryz
3 years agoExplorer | Level 3
Error 400 using download link from embedded code
I have an embedded piece of code that once upon a time worked before TLS v1 was deprecated. Note the URL download link in the subject line above was modified to protect the file. The unmodified link works fine with Chrome and Edge as the client. I have been trying to modify the code in my embedded application to use TLS v1.2 to make it work again. Below is the code snippet that I am trying to modify. I am guessing my header {} settings are incorrect. Below the code is the html response I get back from Dropbox - basically error 400. Do I need to create my own agent to do this or did I not put in the correct header {} information? I am using the typical Edge and Chrome header for 'Agent'...
Code:
local https = require("ssl.https")
local ltn12 = require("ltn12")
local options = {}
local fileMode = isbinary and "wb" or "w"
f = io.open(fulllocalpath, fileMode)
if not f then
resultstr = "Failed to open local file for writing:" .. fulllocalpath .."\r"
return false, nil, nil, resultstr
end
options = {
url = rawname,
sink = ltn12.sink.file(f),
protocol = "tlsv1_2",
headers = { --IS THERE SOMETHING WRONG HERE???
["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36",
["Accept"] = "*/*",
["Accept-Encoding"] = "gzip, deflate, br",
["Connection"] = "keep-alive"
}
}
Here is the html response back from Dropbox:
<.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> </body> </html>
32 Replies
Replies have been turned off for this discussion
- terryz3 years agoExplorer | Level 3
Here is my log showing what is going on, getting the inital 400 error, but still getting the file. You can see the inital error 400 received, followed by the header received back which includes the redirect URL. Followed by a call back to the redirect URL and showing file downloaded successfully (The file is indeed downloaded correctly).
Downloading text file: commands.UpdateControllerConfigFile
Starting download to local directory: cfgNfw/TEST7.CSV
Download From: https://www.dropbox.com/s/y5jlwu5nfr3s8xe/FAULTMSG.CSV?dl=1
File download resultcode [400].
headers: x-dropbox-response-origin:local
headers: content-type:text/html
headers: location:https://ucaa969fc16fd56378489df5cb52.dl.dropboxusercontent.com/cd/0/get/B-0OSKvdAZc91gDuj8YBWre69-DxytXtn44Y7-kXdpU8m-vue83sIyIpfK_N0MAr3wMyBHORLcXERx97xHpNcQ-06t1j1OKAQ_ptuboeTGDNl6q-1LAuHYSoPJqQPTkzT0CMNEKcYxZLMtDgl6nYkQMlWHWNpteJigtWDt9VkdAL-e8cCesb4KWfVfV2UigPgsY/file?dl=1#
headers: vary:Accept-Encoding
headers: content-length:1005
headers: connection:close
headers: date:Wed, 28 Jun 2023 13:22:17 GMT
headers: server:envoy
Redirecting to: [https://ucaa969fc16fd56378489df5cb52.dl.dropboxusercontent.com/cd/0/get/B-0OSKvdAZc91gDuj8YBWre69-DxytXtn44Y7-kXdpU8m-vue83sIyIpfK_N0MAr3wMyBHORLcXERx97xHpNcQ-06t1j1OKAQ_ptuboeTGDNl6q-1LAuHYSoPJqQPTkzT0CMNEKcYxZLMtDgl6nYkQMlWHWNpteJigtWDt9VkdAL-e8cCesb4KWfVfV2UigPgsY/file?dl=1].
Redirect Count: 1.
File download resultcode [200].
File Downloaded Successfully
Successfully downloaded file: TEST7.CSV to gateway. - Greg-DB3 years ago
Dropbox Community Moderator
terryz I'm glad to hear you got this working!
When starting from a /s/...?dl=1 link, there may be multiple redirects that need to be followed, which the client would handle do by issuing multiple requests. A 400 error response indicates that that particular request (that is, the one to which the response is sent) was invalid in some way. For instance, clients are automatically supposed to not include the fragment, but it sounds like you were able to work around that issue.
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!