cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

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

[PHP] /files/list_folder returns Curl Error 51

[PHP] /files/list_folder returns Curl Error 51

straightvisions
New member | Level 2

Related SDK and Issue:
https://github.com/kunalvarma05/dropbox-php-sdk/issues/100

 

 

Warning: cURL error 51: SSL: no alternative certificate subject name matches target host name 'api.dropboxapi.com' (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)


Test Script

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.dropboxapi.com/2/files/list_folder");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CAINFO, "cacert.pem");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"path\":\"\"}");
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Authorization: Bearer <TOKEN>";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

var_dump($result);


When I use api.dropbox.com, /files/list_folder works, but not /files/download:

Incorrect host for API function files/download. You must issue the request to content.dropboxapi.com

Needless to say that content.dropbox.com isn't available in v2.

 

2 Replies 2

Greg-DB
Dropbox Staff

The api.dropboxapi.com host is currently being served with a valid certificate, so it's not clear why your client isn't trusting it. (Is there any security software, e.g., firewall, or a proxy that may be intefering?)

 

In any case, the /2/files/list_folder endpoint does need to be called on the Dropbox API servers, for which either of these host names are valid:

  • api.dropbox.com
  • api.dropboxapi.com

 

The  /2/files/download endpoint does need to be called on the Dropbox API content servers, for which either of these host names are valid:

  • api-content.dropbox.com
  • content.dropboxapi.com

 

(Note that at the end of your post you mentioned "content.dropbox.com isn't available in v2". That is true in that "content.dropbox.com" is not a valid host name, but "content.dropboxapi.com" is valid and does serve API v2.)

straightvisions
New member | Level 2

Thank you for your detailed answer. Based on this, I was able to track down the bug, which was indeed a wrong content url.

Thank you, issue solved.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    straightvisions New member | Level 2
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?