We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
Scafol
7 years agoExplorer | Level 3
Dropbox CORS cannot download file
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
- TaylorKrusen7 years ago
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?
About Discuss Dropbox Developer & API
Make connections with other developers815 PostsLatest Activity: 6 years ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or 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!