Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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 }) }; });
[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:
Hi there!
If you need more help you can view your support options (expected response time for a 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!