cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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 file download returns page not found

PHP file download returns page not found

steve_lae0901
Helpful | Level 6

using cURL in PHP to call the /files/download api.  Dropbox returns "Error (4xx) We can't find the page you're looking for."  How to troubleshoot? I think I am using the API correctly.

 

function getTextFile( $token )
{
  $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, "https://content.dropboxapi.com/2/files/download");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0 ) ;

  $headers = array();
  $headers[] = "Authorization: Bearer " . $token ;
  $headers[] = "Dropbox-Api-Arg: {\"path\": \"/test_upload.txt\"}";
  $headers[] = 'Content-Type: text/plain; charset=utf-8' ;
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

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

 

 

4 Replies 4

Greg-DB
Dropbox Staff
I don't see anything clearly wrong here. (We recommend not disabling SSL verification though.)

Anyway, it's possible to get that generic 4xx error if the HTTP request itself is malformed. For example, perhaps $token is leaking an invalid value into the Authorization header. Can you check that it is the access token string only?

steve_lae0901
Helpful | Level 6

Thanks for the help Greg.

 

I run this code on a PHP hosting site and it works. Run it on our production ZEND PHP server and it fails.    So I do not know what to do.  For now I am going to have the hosting site get the files from dropbox. Then use cURL to send the data from the hosting site  to the production server.


I ran the code with CURLOPT_HEADERFUNCTION.  Got this back:

HTTP/1.1 400 Bad Request 
Server: nginx 
Date: Thu, 08 Feb 2018 22:26:12 GMT 
Content-Type: text/html 
Content-Length: 25658 
Connection: close 
ETag: "5a0b785f-643a" 
X-Dropbox-Request-Id: 0acd4bd5e915ad747d40dfaff467b9ca 
X-Robots-Tag: noindex, nofollow, noimageindex 
 
 

steve_lae0901
Helpful | Level 6

this PHP code works on a server running PHP 7.0.27.  It is failing on PHP 5.6.15.

 

Greg-DB
Dropbox Staff
The output you shared is from the response. Can you inspect the request itself?
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    steve_lae0901 Helpful | Level 6
What do Dropbox user levels mean?