cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to download file from Dropbox using javascript dropbox api

How to download file from Dropbox using javascript dropbox api

Issac J.
New member | Level 1

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...???

1 Reply 1
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Steve M. Dropbox Staff
What do Dropbox user levels mean?