Take Your Search Game to the Next Level with Dropbox Dash  🚀✨ Curious how it works? Ask us here! 

Forum Discussion

terryz's avatar
terryz
Explorer | Level 3
2 years ago

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???
                ["Host"] = "www.dropbox.com",
                ["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"] = "*/*",
                ["Referer"] = "https://www.dropbox.com/",
                ["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

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,010 PostsLatest Activity: 16 hours ago
391 Following

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!