<?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 Re: Can't upload xlsx file to dropbox app in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171783#M6503</link>
    <description>&lt;P&gt;Yes, for these calls with the parameters in the header, you need to escape these characters. That is, when you use the “Dropbox-API-Arg” header, you need to make it “HTTP header safe”. This means using JSON-style “\uXXXX” escape codes for the character 0x7F and all non-ASCII characters.&lt;/P&gt;
&lt;P&gt;Some, but not all, languages/libraries do this for you. For example, for JavaScript, to&amp;nbsp;do this yourself you could do something like this:&lt;/P&gt;
&lt;PRE&gt;var charsToEncode = /[\u007f-\uffff]/g;&lt;BR /&gt;function http_header_safe_json(v) {&lt;BR /&gt; return JSON.stringify(v).replace(charsToEncode,&lt;BR /&gt; function(c) { &lt;BR /&gt; return '\\u'+('000'+c.charCodeAt(0).toString(16)).slice(-4);&lt;BR /&gt; }&lt;BR /&gt; );&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;and then:&lt;/P&gt;
&lt;PRE&gt;"Dropbox-API-Arg": http_header_safe_json(arg)&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Jun 2016 04:07:22 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2016-06-21T04:07:22Z</dc:date>
    <item>
      <title>Can't upload xlsx file to dropbox app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171780#M6500</link>
      <description>&lt;P&gt;Hi guys, as the title says, I'm unable to upload an xlsx file, I can successfully upload other formats as xls, pdf, ppt, etc. but this gives an error in the moment I'm trying to upload it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The call is via AJAX (jQuery), something like this:&lt;/P&gt;
&lt;P&gt;$.ajax({&lt;BR /&gt; url: '&lt;A href="https://content.dropboxapi.com/2/files/upload" rel="nofollow noreferrer" target="_blank"&gt;https://content.dropboxapi.com/2/files/upload&lt;/A&gt;',&lt;BR /&gt; type: "POST",&lt;BR /&gt; processData: false,&lt;BR /&gt; headers: {&lt;BR /&gt; "Authorization": token,// My app token&lt;BR /&gt; "Dropbox-API-Arg": JSON.stringify(arg),&lt;BR /&gt; "Content-Type": "application/octet-stream"&lt;BR /&gt; },&lt;BR /&gt; data: b64toBlob(f.content, f.type),&lt;BR /&gt;success = ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JSON.stringify(arg) gives:&lt;/P&gt;
&lt;P&gt;{"path":"/test_api1425/Base referencia histórica.xlsx","mode":"overwrite","autorename":true,"mute":false}&lt;/P&gt;
&lt;P&gt;f.type is "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" (the same for an old xls file).&lt;/P&gt;
&lt;P&gt;f.content is a base64 encodede string which I convert to blob before sending.&lt;/P&gt;
&lt;P&gt;And the error I get is "POST &lt;A href="https://content.dropboxapi.com/2/files/upload" rel="nofollow noreferrer" target="_blank"&gt;https://content.dropboxapi.com/2/files/upload&lt;/A&gt; 400 (Bad Request)"&lt;/P&gt;
&lt;P&gt;As I said, this setup works with any file, except *.xlsx files, since I've seen here in the formus this excel files have some issues, I wonder if this has something to do and if you're able to reproduce it, many thanks for your help.&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR /&gt;Gustavo.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:32:34 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171780#M6500</guid>
      <dc:creator>Gustavo L.5</dc:creator>
      <dc:date>2019-05-29T09:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can't upload xlsx file to dropbox app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171781#M6501</link>
      <description>&lt;P&gt;Hi Gustavo, the output&amp;nbsp;you shared is just the status line. The body of the response should contain a more useful error message. Please check that and share it here if you still need help with it.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 01:45:59 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171781#M6501</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-06-21T01:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can't upload xlsx file to dropbox app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171782#M6502</link>
      <description>&lt;P&gt;Playing a little more with this I noticed the error is because of some "special" characters in the json sent (specifically the path of the file).&amp;nbsp;So this seems like an encoding issue, when I send a file which contains an 'ó' in the name, it gives this error:&lt;/P&gt;
&lt;P&gt;{"readyState":4,"responseText":"Error in call to API function \"files/upload\": HTTP header \"Dropbox-API-Arg\": could not decode input as JSON","status":400,"statusText":"Bad Request"}&lt;/P&gt;
&lt;P&gt;but if I change that 'ó' by an 'o' (with no accent) it works well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been playing with contentType parameter in the ajax call but I can't make it work, any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 03:56:11 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171782#M6502</guid>
      <dc:creator>Gustavo L.5</dc:creator>
      <dc:date>2016-06-21T03:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can't upload xlsx file to dropbox app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171783#M6503</link>
      <description>&lt;P&gt;Yes, for these calls with the parameters in the header, you need to escape these characters. That is, when you use the “Dropbox-API-Arg” header, you need to make it “HTTP header safe”. This means using JSON-style “\uXXXX” escape codes for the character 0x7F and all non-ASCII characters.&lt;/P&gt;
&lt;P&gt;Some, but not all, languages/libraries do this for you. For example, for JavaScript, to&amp;nbsp;do this yourself you could do something like this:&lt;/P&gt;
&lt;PRE&gt;var charsToEncode = /[\u007f-\uffff]/g;&lt;BR /&gt;function http_header_safe_json(v) {&lt;BR /&gt; return JSON.stringify(v).replace(charsToEncode,&lt;BR /&gt; function(c) { &lt;BR /&gt; return '\\u'+('000'+c.charCodeAt(0).toString(16)).slice(-4);&lt;BR /&gt; }&lt;BR /&gt; );&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;and then:&lt;/P&gt;
&lt;PRE&gt;"Dropbox-API-Arg": http_header_safe_json(arg)&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jun 2016 04:07:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171783#M6503</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-06-21T04:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can't upload xlsx file to dropbox app</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171784#M6504</link>
      <description>&lt;P&gt;That solved the problem, didn't know about the safe header thing, thanks!&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR /&gt;Gustavo.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 05:05:09 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-upload-xlsx-file-to-dropbox-app/m-p/171784#M6504</guid>
      <dc:creator>Gustavo L.5</dc:creator>
      <dc:date>2016-06-21T05:05:09Z</dc:date>
    </item>
  </channel>
</rss>

