<?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 files/download giving 400 with an HTML page body from one host but not another in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202439#M9611</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm a developer on UpdraftPlus, a WordPress backup plugin with around 250,000 users who send to their Dropbox.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We're having a problem with a few users who, when trying to download their backups, get an HTTP 400 code. We have now been given access to a site where this happens, and produced a simple test script (PHP, using curl) that makes a single POST to &lt;A href="https://content.dropboxapi.com/2/files/download" target="_blank"&gt;https://content.dropboxapi.com/2/files/download&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The test script contains all hard-coded details (e.g. the Authorization: header and download path). When this test script is run on our PHP install, it always succeeds: i.e. the expected file from the user's Dropbox is downloaded. However, when the identical PHP script is run on our user's PHP install, it always fails with an HTTP 400 error. The body returned is not JSON or error data, but HTML. If you save it and then view the HTML in a browser it looks like the screenshot I've appended at the bottom of this message (also see at &lt;A href="https://snag.gy/QHiLqY.jpg" target="_self"&gt;https://snag.gy/QHiLqY.jpg&lt;/A&gt; ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a pastebin for the test script - as I say, on our server it always successfully downloads the user's file; on his, the identical script always fails with the 400 result: &lt;A href="http://pastebin.com/FKbqK4Tx" target="_self"&gt;http://pastebin.com/FKbqK4Tx&lt;/A&gt;. It also always succeeds if I try the same parameters via a command-line call to /usr/bin/curl on our test machine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the headers returned from one of the failing requests, including the X-Dropbox-Request-Id header. Does this allow you to see what the cause of the problem is? On our test (succeeding) server we have PHP 5.6.29 with curl 7.47.1; on the user's (failing) server there is PHP 5.6.29 (i.e. same) and curl 7.24.0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTTP/1.1 400 Bad Request&lt;BR /&gt;Server: nginx&lt;BR /&gt;Date: Mon, 16 Jan 2017 23:05:23 GMT&lt;BR /&gt;Content-Type: text/html&lt;BR /&gt;Content-Length: 25457&lt;BR /&gt;Connection: close&lt;BR /&gt;ETag: "5876c90b-6371"&lt;BR /&gt;X-Dropbox-Request-Id: 68d4e441234efb60f425fe2163654e22&lt;BR /&gt;X-Robots-Tag: noindex, nofollow, noimageindex&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;David Anderson&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://i.snag.gy/QHiLqY.jpg" alt="Returned body" width="652" height="599" border="0" /&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:26:43 GMT</pubDate>
    <dc:creator>David A.114</dc:creator>
    <dc:date>2019-05-29T09:26:43Z</dc:date>
    <item>
      <title>files/download giving 400 with an HTML page body from one host but not another</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202439#M9611</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm a developer on UpdraftPlus, a WordPress backup plugin with around 250,000 users who send to their Dropbox.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We're having a problem with a few users who, when trying to download their backups, get an HTTP 400 code. We have now been given access to a site where this happens, and produced a simple test script (PHP, using curl) that makes a single POST to &lt;A href="https://content.dropboxapi.com/2/files/download" target="_blank"&gt;https://content.dropboxapi.com/2/files/download&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The test script contains all hard-coded details (e.g. the Authorization: header and download path). When this test script is run on our PHP install, it always succeeds: i.e. the expected file from the user's Dropbox is downloaded. However, when the identical PHP script is run on our user's PHP install, it always fails with an HTTP 400 error. The body returned is not JSON or error data, but HTML. If you save it and then view the HTML in a browser it looks like the screenshot I've appended at the bottom of this message (also see at &lt;A href="https://snag.gy/QHiLqY.jpg" target="_self"&gt;https://snag.gy/QHiLqY.jpg&lt;/A&gt; ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a pastebin for the test script - as I say, on our server it always successfully downloads the user's file; on his, the identical script always fails with the 400 result: &lt;A href="http://pastebin.com/FKbqK4Tx" target="_self"&gt;http://pastebin.com/FKbqK4Tx&lt;/A&gt;. It also always succeeds if I try the same parameters via a command-line call to /usr/bin/curl on our test machine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the headers returned from one of the failing requests, including the X-Dropbox-Request-Id header. Does this allow you to see what the cause of the problem is? On our test (succeeding) server we have PHP 5.6.29 with curl 7.47.1; on the user's (failing) server there is PHP 5.6.29 (i.e. same) and curl 7.24.0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTTP/1.1 400 Bad Request&lt;BR /&gt;Server: nginx&lt;BR /&gt;Date: Mon, 16 Jan 2017 23:05:23 GMT&lt;BR /&gt;Content-Type: text/html&lt;BR /&gt;Content-Length: 25457&lt;BR /&gt;Connection: close&lt;BR /&gt;ETag: "5876c90b-6371"&lt;BR /&gt;X-Dropbox-Request-Id: 68d4e441234efb60f425fe2163654e22&lt;BR /&gt;X-Robots-Tag: noindex, nofollow, noimageindex&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;David Anderson&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://i.snag.gy/QHiLqY.jpg" alt="Returned body" width="652" height="599" border="0" /&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:26:43 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202439#M9611</guid>
      <dc:creator>David A.114</dc:creator>
      <dc:date>2019-05-29T09:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: files/download giving 400 with an HTML page body from one host but not another</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202584#M9635</link>
      <description>&lt;P&gt;Thanks for the detailed report! Unfortunately, the request ID isn't enough to see what the issue is in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With issues like this, where an API call receives an HTML response, it's generally because the HTTP request for the API call was mangled such that the&amp;nbsp;Dropbox API servers weren't able to recognize it as an API request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a few ways for that to happen, and I suspect it's related to the different versions of curl in use here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To help debug this, can you print out the raw HTTP request for the failing call, similar to how you shared the raw response? Be sure to redact the access token of course, but please include everything else.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 21:39:14 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202584#M9635</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-01-17T21:39:14Z</dc:date>
    </item>
    <item>
      <title>reg,TRe: files/download giving 400 with an HTML page body from one host but not another</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202588#M9636</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the response. When you say that you want to see the raw HTML request, can you be more specific? I linked to a PHP script which reproduces the issue every time (when run from certain servers (but works every time from others) in my previous post; it's here: &lt;A href="http://pastebin.com/FKbqK4Tx" target="_blank"&gt;http://pastebin.com/FKbqK4Tx&lt;/A&gt; - there's only 6 lines of PHP needed from there to reproduce it (plus a few debug lines for more info). Were you wanting something different to that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 22:17:16 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202588#M9636</guid>
      <dc:creator>David A.114</dc:creator>
      <dc:date>2017-01-17T22:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: reg,TRe: files/download giving 400 with an HTML page body from one host but not another</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202589#M9637</link>
      <description>I'd specifically like to see the raw HTTP (not HTML) request for the API call that results in the 400 HTTP response (which happens to contain HTML).&lt;BR /&gt;&lt;BR /&gt;I tried the script you provided, but it doesn't reproduce the issue on my machine.</description>
      <pubDate>Tue, 17 Jan 2017 22:19:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202589#M9637</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-01-17T22:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: reg,TRe: files/download giving 400 with an HTML page body from one host but not another</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202592#M9638</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks. Working through that revealed the cause of the problem. When you POST to /2/files/download in the older version of Curl, with an empty body, Curl adds a header:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Content-Length: -1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The newer version of Curl does not add that header.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Explicitly adding a...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Content-Length: 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;... to the request avoids the problem. Switching to GET also avoids it (as in that case, there's no Content-Length header from the client).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know which version of curl changed this behaviour. Perhaps if you tweak your API servers to treat negative content-lengths as equivalent to zero, that will help a few people out there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 23:01:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-download-giving-400-with-an-HTML-page-body-from-one-host/m-p/202592#M9638</guid>
      <dc:creator>David A.114</dc:creator>
      <dc:date>2017-01-17T23:01:46Z</dc:date>
    </item>
  </channel>
</rss>

