cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Discuss Dropbox Developer & API

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

Dropbox CORS cannot download file

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
Highlighted

Re: Dropbox CORS cannot download file

Dropboxer
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
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

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.
Need more support?