cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you new to Dropbox? Our Newcomers group is the perfect place to learn the basics, find out more here.

Discuss Dropbox Developer & API

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

Dropbox CORS cannot download file

Dropbox CORS cannot download file

Scafol
Explorer | Level 3

I'm following this guide https://dropbox.github.io/dropbox-api-v2-explorer/#files_download_zip

I've problem when using api dropbox and want to get download files. first is about cors problem.

$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://content.dropboxapi.com/2/files/download_zip');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);$headers = array();$headers[] = 'Authorization: Bearer myTokenAcess';$headers[] = 'Dropbox-Api-Arg: {\"path\":\"/myfolder/mysubfolder/mysubfolderagain\"}';curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);$result = curl_exec($ch);
if (curl_errno($ch)) {    echo 'Error:' . curl_error($ch);
}curl_close($ch);

and the results is

Error in call to API function "files/download": Bad HTTP "Content-Type" header: "application/x-www-form-urlencoded". Expecting one of "text/plain", "text/plain; charset=utf-8", "application/octet-stream", "application/octet-stream; charset=utf-8".

then I'm trying to add this line on header

$headers[] = 'Content-Type: application/octet-stream';

the results be

Error in call to API function "files/download": HTTP header "Dropbox-API-Arg": could not decode input as JSON

and then I'm trying to change drobox-api-arg line to

$headers[] = 'Dropbox-Api-Arg: json_decode({\"path\":\"/myfolder/mysubfolder/mysubfolderagain\"},TRUE)';

and the results still same like above

Error in call to API function "files/download": HTTP header "Dropbox-API-Arg": could not decode input as JSON

can someone help me to fix this?

1 Reply 1

TaylorKrusen
Dropbox Staff

I think you may have included the wrong link in the beginning. Could you link to the guide that you're following along with?

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    TaylorKrusen Dropbox Staff
What do Dropbox user levels mean?