Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Issac J.'s avatar
Issac J.
New member | Level 1
10 years ago

How to download file from Dropbox using javascript dropbox api

I tried to download a file from Dropbox using Core Api with javascript(without using chooser api). Here is the method I have written.

  function download(path, token){  
      var url = "https://api-content.dropbox.com/1/files/auto/" + path;
      var result;
      var xhr = new XMLHttpRequest(); 
      xhr.onreadystatechange = function() {
        if (xhr.readyState === 4 && xhr.status === 200) {
           result = xhr.responseText;
        }
      }
  xhr.open("GET", url, true);
  xhr.setRequestHeader("Authorization", "Bearer " + token);
  xhr.send();  
}

Here is the response I got.

<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx</center>
</body>
</html>


 Any idea about what's wrong with this code...???

About Dropbox API Support & Feedback

Node avatar for 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!