<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Cannot Download File by using API in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531673#M2004</link>
    <description>&lt;P&gt;I've tried to download a file using Dropbox API &amp;amp; PHP with the following code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;                $out_fp = fopen($local_tmp_file_path, 'w+');
		
		$headers = array(	'Authorization: Bearer '. $DROPBOX_TOKEN,
					'Content-Type:',
					'Dropbox-API-Arg: '. json_encode(array(
					"path"=&amp;gt; '/file_data/tmp/2021_07/191.png'
				))
		);
		
		$ch = curl_init('https://content.dropboxapi.com/2/files/download');
		curl_setopt($ch, CURLOPT_POST, TRUE);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_FILE, $out_fp);
		
		$response = curl_exec($ch);
		$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
		
		fclose($out_fp);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code run, and I always received a file the content like "Error Something went wrong. Don't worry, your files are still safe and the Dropboxers have been notified. Check out our Help Center and forums for help, or head back to home" !?!?!.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried to download other files, but the problem still same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have trouble with upload file by the way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jul 2021 13:22:00 GMT</pubDate>
    <dc:creator>ckienquoc</dc:creator>
    <dc:date>2021-07-08T13:22:00Z</dc:date>
    <item>
      <title>Cannot Download File by using API</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531673#M2004</link>
      <description>&lt;P&gt;I've tried to download a file using Dropbox API &amp;amp; PHP with the following code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;                $out_fp = fopen($local_tmp_file_path, 'w+');
		
		$headers = array(	'Authorization: Bearer '. $DROPBOX_TOKEN,
					'Content-Type:',
					'Dropbox-API-Arg: '. json_encode(array(
					"path"=&amp;gt; '/file_data/tmp/2021_07/191.png'
				))
		);
		
		$ch = curl_init('https://content.dropboxapi.com/2/files/download');
		curl_setopt($ch, CURLOPT_POST, TRUE);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_FILE, $out_fp);
		
		$response = curl_exec($ch);
		$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
		
		fclose($out_fp);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code run, and I always received a file the content like "Error Something went wrong. Don't worry, your files are still safe and the Dropboxers have been notified. Check out our Help Center and forums for help, or head back to home" !?!?!.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried to download other files, but the problem still same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have trouble with upload file by the way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 13:22:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531673#M2004</guid>
      <dc:creator>ckienquoc</dc:creator>
      <dc:date>2021-07-08T13:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Download File by using API</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531740#M2005</link>
      <description>&lt;P&gt;Based on the error message, it looks like the HTTP request may have been malformed, causing the call to fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see you're supplying an empty 'Content-Type:', but that may not be the cause. I just tried this code myself, plugging in my own test&amp;nbsp; access token and path, and it worked for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you check that your $DROPBOX_TOKEN value is valid and doesn't contain any stray characters, such as whitespace, etc.?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, you can set the following to enable extra output for debugging:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;curl_setopt($ch, CURLOPT_VERBOSE, TRUE);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you share the output, be sure to redact your access token.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 15:54:19 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531740#M2005</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-07-08T15:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Download File by using API</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531843#M2007</link>
      <description>&lt;P&gt;This is the debug result. I've got error 400 [Bad request].&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to run the same source on localhost environment and it works fine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code only have problem with download (Upload is OK) when I run it on Development server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also added the&amp;nbsp;OAuth 2 Redirect Uris for both environments. One for localhost and one for&amp;nbsp;&lt;A href="https://my_website.com" target="_blank"&gt;https://my_website.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help! Thank You&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;* About to connect() to content.dropboxapi.com port 443 (#2)
*   Trying 162.125.82.14...
* Connected to content.dropboxapi.com (162.125.82.14) port 443 (#2)
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* 	subject: CN=content.dropboxapi.com,O="Dropbox, Inc",L=San Francisco,ST=California,C=US,serialNumber=4348296,incorporationState=Delaware,incorporationCountry=US,businessCategory=Private Organization
* 	start date: Jan 28 00:00:00 2021 GMT
* 	expire date: Feb 01 23:59:59 2022 GMT
* 	common name: content.dropboxapi.com
* 	issuer: CN=DigiCert SHA2 Extended Validation Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US
&amp;gt; POST /2/files/download HTTP/1.1
Host: content.dropboxapi.com
Accept: */*
Authorization: Bearer MY_TOKENXXXXXXXXXXXXXXXXXXXX
Content-Type: application/octet-stream
Dropbox-API-Arg: {"path":"\/file_data\/shared\/IMPORT_DEPARTMENT_TMP_vn.xlsx"}
Content-Length: -1
Expect: 100-continue

&amp;lt; HTTP/1.1 400 Bad Request
&amp;lt; Content-Length: 14468
&amp;lt; Content-Type: text/html
&amp;lt; Vary: Accept-Encoding
&amp;lt; X-Dropbox-Response-Origin: local
&amp;lt; Date: Fri, 09 Jul 2021 02:44:18 GMT
&amp;lt; Server: envoy
&amp;lt; Connection: close
&amp;lt; 
* Closing connection 2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 02:57:58 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531843#M2007</guid>
      <dc:creator>ckienquoc</dc:creator>
      <dc:date>2021-07-09T02:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Download File by using API</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531968#M2009</link>
      <description>&lt;P&gt;Thanks, that's helpful. I see your client is passing up 'Content-Length: -1', which is incorrect. Mine is not doing that, so it may depend on what version of curl/PHP you're using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try explicitly specifying a header of: 'Content-Length: 0'.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 16:17:12 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/531968#M2009</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-07-09T16:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Download File by using API</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/532093#M2011</link>
      <description>&lt;P&gt;Awesome! thank you so much &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@F11ED489607C201719DC4AF19786AEF5/emoticons/2764.png" alt=":red_heart:" title=":red_heart:" /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jul 2021 12:52:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-Download-File-by-using-API/m-p/532093#M2011</guid>
      <dc:creator>ckienquoc</dc:creator>
      <dc:date>2021-07-10T12:52:35Z</dc:date>
    </item>
  </channel>
</rss>

