cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Check out the Dropbox cheat sheet for getting started in 2021 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

Explorer | Level 3

I'm following this guide https:confused face:/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

Re: Dropbox CORS cannot download file

Dropboxer

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

Polls
Are you starting new work habits this year?

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?