cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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

Re: How to download file from Dropbox using javascript dropbox api

Steve M.
Dropboxer
Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Steve M. Dropboxer
What do Dropbox user levels mean?
Need more support?