Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I want to implement a functionality that user can login to their dropbox account by my web application and i want to show all folder of dropbox on my web application screen . How can i do this .
What do you mean by "it returns nothing"?
This part looks wrong:
'Content-Type: ', 'Authorization: Bearer ' . $key
But in general, the API returns pretty clear error messages that tell you what is wrong with a request, so make sure you're able to read the HTTP response bodies even when an error occurs.
Now am using
CURLOPT_HTTPHEADER => array( 'Authorization: Bearer ' . $key, 'Dropbox-API-Arg:' . $data),
but it giving me below error.
Error in call to API function "files/download": You provided a non-empty HTTP "Content-Type" header ("application/x-www-form-urlencoded"). This API function requires that the header be missing or empty.
Can you please tell me what parameter should i pass to get response
Sorry, I think I steered you wrong. Your Content-Type header was fine... here's code that's working for me:
$accessToken = '<REDACTED>';
$ch = curl_init();
$data = json_encode(array('path' => '/test.txt'));
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://content.dropboxapi.com/2/files/download',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => array("Content-Type:", "Authorization: Bearer $accessToken", "Dropbox-API-Arg: $data"),
));
$output = curl_exec($ch);
curl_close($ch);
echo $output;
An alternative (drop both CURLOPT_POST and the Content-Type header):
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://content.dropboxapi.com/2/files/download',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array("Authorization: Bearer $accessToken", "Dropbox-API-Arg: $data"),
));
Now am using above code. Error is removed now but its not returning any response.
If you're not getting an error, the response should be the file content. Is it possible the file is 0 bytes? You can check on the Dropbox web site.
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!