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: 

download file API stopped working with 400 error

download file API stopped working with 400 error

wind75423
Explorer | Level 3

I use download file API , and i got a token , but it's return 400 bea request error
"Error in call to API function "files/download": Must provide HTTP header "Authorization" or URL parameter "authorization"

How do I fix it ?

this is my code ( angular2 )

downloadFile(fileid){
let headers = new Headers();
headers.append('Authorization', 'Bearer ' + this.accessToken);
headers.append('Dropbox-API-Arg','path:'+ fileid);
return this.http.post('https://content.dropboxapi.com/2/files/download',new RequestOptions({ headers: headers ,responseType:ResponseContentType.ArrayBuffer})).map((res) => {
let arrayBuffer = res.arrayBuffer();
let contentType = res.headers.get('content-type');
return {
fileid: fileid,
blob: new Blob([arrayBuffer], { type: contentType })
};
});

 

1 Reply 1

Greg-DB
Dropbox Staff

[Cross-linking for reference: https://stackoverflow.com/questions/42755495/dropbox-download-file-api-stopped-working-with-400-erro... ]

 

The error message is indicating that the access token isn't being supplied with the request properly. I can't offer much help with using the HTTP client in Angular, but here's a simplified version that works for me:

 

let headers = new Headers();
headers.append('Authorization', 'Bearer <ACCESS_TOKEN>');
headers.append('Dropbox-API-Arg','{"path": "/test.txt"}');
console.log(headers);
http.post('https://content.dropboxapi.com/2/files/download', null,
    new RequestOptions(
        {
            headers: headers,
            responseType: ResponseContentType.ArrayBuffer}
        )
    )
.subscribe((res) => {console.log(res)});

 

There were two main options:

 

  1. You were passing the request options to the data parameter, instead of the config parameter of http.post.
  2. You weren't passing in valid JSON as the 'Dropbox-API-Arg' value.

 

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?