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 lin...
terryz
3 years agoExplorer | Level 3
Correct, it was dl=1.
What I am getting back is the following header to the URL https://www.dropbox.com/s/y5jlwu5nfr3s8xe/FAULTMSG.CSV?dl=1 is the following;
Why am I getting back a response of 400 with a redirect link?
resultcode [400].
headers: x-dropbox-response-origin:local
headers: content-type:text/html
headers: location:https://uc16524db6bb71d5534145f43f41.dl.dropboxusercontent.com/cd/0/get/B-y6cEeORVMMdIB4gjagTUX1yqaznPpvtxEAaIMWaMgYvlPnz9gApnmN5Uh_Ol6TeuDQYDw5RVdUfpnhcrRyzWvx6e9jtmqpHChrnTp3lXMjGweuZPtT1dHIeSpCSlrGswTQc-fr6mhCFf5c9QNCUxEam3dIxAqAJvp30KVhoaeum4dSAVdzecaqBBgvWpzQOjQ/file?dl=1#
headers: vary:Accept-Encoding
headers: content-length:1005
headers: connection:close
headers: date:Tue, 27 Jun 2023 20:03:08 GMT
headers: server:envoy
Greg-DB
Dropbox Community Moderator
3 years agoA 400 like that indicates that there was something incorrect about the HTTP request issued by the client. (When following the redirects from the original link, there would be multiple requests made.)
For example, as we found it seems the client is incorrectly sending the fragment ("#") on that particular link.
Ultimately, as this does not reproduce with other clients, it appears this is an issue with the specific network client you're using. That client is not made by Dropbox and the behavior of that client is out of our control so we can't provide support for it in particular.
- terryz3 years agoExplorer | Level 3
Hi - I do take out the '#' on the redirect link.
It is now working with the 'standard' link, however I am still getting a 400 error when I use the standard link https://www.dropbox.com/s/gxxxxxxxxblablahfile.TXT?dl=1. This returns error 400.
So I modified the code to ignore this error 400 and look for the redirect URL anyway, which is provided, despite getting the 400 from dropbox.com.
The code then strips off the trailing '#' character, and reissues new http request with the redirect link. The file is downloaded successfully, and the return code is now 200 - indicating success, which it is!
So...why am I getting a 400 error on the first http request with the standard link, but I still get a redirect URL to the file anyway, and then making the exact same http request except modifying the url to the redirect link, then get the file downloaded and code 200?
Here is my header setup - what is wrong with it causing the initial error 400?
resp, resultcode, respheaders, respstatus = https.request{
url = rawname,
sink = ltn12.sink.file(io.open(fulllocalpath, "wb")),
protocol = "tlsv1_2",
verify = "none",
options = "all",
--method = "GET",
headers = {
["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
["Accept"] = "*/*",
["Connection"] = "keep-alive"
}
} - 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!