<?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 File upload error code 500 in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371268#M20918</link>
    <description>&lt;P&gt;I am trying to upload a PDF in my javascript file but i get server response error code 500. I also need to find what i have to put in the body to upload the pdf file (using netsuite so i cant use the dropbox-sdk). I am now encoding my pdf from Base64 (that is what it is on my server) and outputEncoding is UTF-8 does this work&amp;gt;&lt;/P&gt;
&lt;PRE&gt;function uploadFile(key, path, file) {

    var URL = 'https://content.dropboxapi.com/2/files/upload';

//converting my file from base_64 to UTF_8
    var body = encode.convert({
      string: file,
      inputEncoding: encode.Encoding.BASE_64,
      outputEncoding: encode.Encoding.UTF_8
    });

//header for Dropbox
    var headers = {
      "Authorization": 'Bearer '+ key,
      "Dropbox-API-Arg":{"path":"/home/1.pdf","mode":"add","autorename":true,"mute":false,"strict_conflict":false},
      "Content-Type": "application/octet-stream",
    };
    
//netsuite specific
    log.debug({
      title: "debug",
      details: body
    });

//the post to https
    var response = https.post({
      url: URL,
      body: body,
      headers: headers
    });

//below function is netsuite specific
    log.debug({
      title: 'Dropbox server response',
      details: JSON.stringify(response)
    });



  }&lt;/PRE&gt;</description>
    <pubDate>Mon, 14 Oct 2019 15:03:25 GMT</pubDate>
    <dc:creator>levi12drie</dc:creator>
    <dc:date>2019-10-14T15:03:25Z</dc:date>
    <item>
      <title>File upload error code 500</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371268#M20918</link>
      <description>&lt;P&gt;I am trying to upload a PDF in my javascript file but i get server response error code 500. I also need to find what i have to put in the body to upload the pdf file (using netsuite so i cant use the dropbox-sdk). I am now encoding my pdf from Base64 (that is what it is on my server) and outputEncoding is UTF-8 does this work&amp;gt;&lt;/P&gt;
&lt;PRE&gt;function uploadFile(key, path, file) {

    var URL = 'https://content.dropboxapi.com/2/files/upload';

//converting my file from base_64 to UTF_8
    var body = encode.convert({
      string: file,
      inputEncoding: encode.Encoding.BASE_64,
      outputEncoding: encode.Encoding.UTF_8
    });

//header for Dropbox
    var headers = {
      "Authorization": 'Bearer '+ key,
      "Dropbox-API-Arg":{"path":"/home/1.pdf","mode":"add","autorename":true,"mute":false,"strict_conflict":false},
      "Content-Type": "application/octet-stream",
    };
    
//netsuite specific
    log.debug({
      title: "debug",
      details: body
    });

//the post to https
    var response = https.post({
      url: URL,
      body: body,
      headers: headers
    });

//below function is netsuite specific
    log.debug({
      title: 'Dropbox server response',
      details: JSON.stringify(response)
    });



  }&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Oct 2019 15:03:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371268#M20918</guid>
      <dc:creator>levi12drie</dc:creator>
      <dc:date>2019-10-14T15:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: File upload error code 500</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371285#M20921</link>
      <description>&lt;P&gt;When uploading data to a&amp;nbsp;Dropbox API &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;"content-upload" style endpoint&lt;/A&gt;, such as &lt;A href="http:/2/files/upload" target="_self"&gt;/2/files/upload&lt;/A&gt;, you should send the raw bytes in the request body as an "application/octet-stream".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're getting a 500 Internal Server Error back, please share a few sample "x-dropbox-request-id" response header values so we can look into it.&amp;nbsp;Thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 15:32:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371285#M20921</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-10-14T15:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: File upload error code 500</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371373#M20927</link>
      <description>&lt;PRE&gt;{
   type: "http.ClientResponse",
   code: 500,
   headers: {
      "Transfer-Encoding": "chunked",
      "X-Dropbox-Request-Id": "d7032e53a533fb8505ea7d99debf3fa3",
      "X-Robots-Tag": "noindex, nofollow, noimageindex",
      Server: "nginx",
      "Content-Security-Policy": "sandbox allow-forms allow-scripts",
      Date: "Mon, 14 Oct 2019 15:10:42 GMT",
      "Content-Type": "text/plain; charset=utf-8",
      Via: "1.1 mono003"
   },
   body: ""
}&lt;/PRE&gt;&lt;P&gt;This is what i got back when trying to upload a file by the code from the original post.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 20:21:14 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371373#M20927</guid>
      <dc:creator>levi12drie</dc:creator>
      <dc:date>2019-10-14T20:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: File upload error code 500</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371391#M20929</link>
      <description>&lt;P&gt;Thanks! It looks like the&amp;nbsp;Dropbox API is having trouble parsing this particular request. Can you print out and share the raw HTTP request, including headers? That should help us reproduce and debug this. (Be sure to redact your access token, and the request body if it's private, of course.)&amp;nbsp;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 21:04:20 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371391#M20929</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-10-14T21:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: File upload error code 500</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371469#M20931</link>
      <description>&lt;PRE&gt;"Authorization": 'Bearer '+ key,
      "Dropbox-API-Arg":{"path":"/home/yes.pdf","mode":"add","autorename":true,"mute":false,"strict_conflict":false},
      "Content-Type": "application/octet-stream"&lt;/PRE&gt;&lt;P&gt;Above the header i am giving.&lt;/P&gt;&lt;P&gt;URL i am using is:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;https://content.dropboxapi.com/2/files/upload&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Here is the pdf from base_64 to utf_8 (partly)&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%PDF-1.3
%����
1 0 obj
&amp;lt;&amp;lt;/Type/Catalog/Pages 4 0 R/Lang(en-US)/Names 3 0 R/Metadata 5 0 R&amp;gt;&amp;gt;
endobj
2 0 obj
&amp;lt;&amp;lt;/Producer(http://bfo.com/products/report?version=1.1.61-r25714)/CreationDate(D:20180703053256-07'00')/ModDate(D:20180703053256-07'00')&amp;gt;&amp;gt;
endobj
3 0 obj
&amp;lt;&amp;lt;/Dests 6 0 R&amp;gt;&amp;gt;
endobj
4 0 obj
&amp;lt;&amp;lt;/Type/Pages/Kids[7 0 R]/Count 1&amp;gt;&amp;gt;
endobj
5 0 obj
&amp;lt;&amp;lt;/Type/Metadata/Subtype/XML/Length 875&amp;gt;&amp;gt;stream
&amp;lt;?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?&amp;gt;
&amp;lt;x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="BFOXMP 1.1.61-r25714"&amp;gt;&amp;lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&amp;gt;&amp;lt;rdf:Description xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about=""&amp;gt;&amp;lt;pdf:Producer&amp;gt;http://bfo.com/products/report?version=1.1.61-r25714&amp;lt;/pdf:Producer&amp;gt;&amp;lt;/rdf:Description&amp;gt;&amp;lt;rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" rdf:about=""&amp;gt;&amp;lt;xmp:CreateDate&amp;gt;2018-07-03T05:32:56-07:00&amp;lt;/xmp:CreateDate&amp;gt;&amp;lt;xmp:ModifyDate&amp;gt;2018-07-03T05:32:56-07:00&amp;lt;/xmp:ModifyDate&amp;gt;&amp;lt;xmp:MetadataDate&amp;gt;2018-07-03T05:32:56-07:00&amp;lt;/xmp:MetadataDate&amp;gt;&amp;lt;/rdf:Description&amp;gt;&amp;lt;rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:about=""&amp;gt;&amp;lt;dc:date&amp;gt;&amp;lt;rdf:Seq&amp;gt;&amp;lt;rdf:li&amp;gt;2018-07-03T05:32:56-07:00&amp;lt;/rdf:li&amp;gt;&amp;lt;/rdf:Seq&amp;gt;&amp;lt;/dc:date&amp;gt;&amp;lt;dc:format&amp;gt;application/pdf&amp;lt;/dc:format&amp;gt;&amp;lt;/rdf:Description&amp;gt;&amp;lt;/rdf:RDF&amp;gt;&amp;lt;/x:xmpmeta&amp;gt;
&amp;lt;?xpacket end='r'?&amp;gt;
endstream
endobj
6 0 obj
&amp;lt;&amp;lt;/Names[(page1)8 0 R]&amp;gt;&amp;gt;
endobj
7 0 obj
&amp;lt;&amp;lt;/Type/Page/MediaBox[0 0 612 792]/Resources&amp;lt;&amp;lt;/ColorSpace&amp;lt;&amp;lt;/DefaultRGB 12 0 R&amp;gt;&amp;gt;/ProcSet[/PDF/ImageI/Text/XObject]/XObject&amp;lt;&amp;lt;/R1 11 0 R/R3 13 0 R&amp;gt;&amp;gt;/Font&amp;lt;&amp;lt;/R2 14 0 R/R4 16 0 R&amp;gt;&amp;gt;&amp;gt;&amp;gt;/Contents[9 0 R]/Parent 4 0 R/Annots 10 0 R&amp;gt;&amp;gt;
endobj
8 0 obj
&amp;lt;&amp;lt;/Type/Action/S/GoTo/D[7 0 R/XYZ 0 792 0]&amp;gt;&amp;gt;
endobj
9 0 obj
&amp;lt;&amp;lt;/Filter/FlateDecode/Length 1748&amp;gt;&amp;gt;stream
x��X�r�6 }�W`�� iF�q'اZ�z��$���!� #��b�TH�n�Q�� ��� i��1E��ݳg/X�kO F a�Ӝ*Ƙ$�SCL �ٺwv���Y��xڛL�� aNT�( �D�QK�� �_ܑ�] "����&amp;gt;���� $�|0R�_��_�W�J#C�U&amp;#12;jYD���k�Z���|��������l]/�2&amp;#12;�M,�6&amp;amp;ڭg (�I�]�0ЬO�Yt&amp;amp; ����i �ә�&amp;lt;@ &amp;gt;�������K � ����W��_����HCDDc� �r�f#���, �n+ =چ2 �(�T ��ۛ�)�nIx�9�&amp;lt;�cӼ�m��� ��(QA��|� ����������ڑ��`�$��S� ��ø{�q�� 4䗁��ܹ;2v��2]$A ## %�6]� 8�m�i�� &amp;gt;&amp;lt; , ���AAlm�hdcr VM�o�e1�b�vH�ɲ|&amp;gt;�-[��t�摔T� ������u�rI�Ȼ&amp;lt;��f% {J�{ �}��ǫ�Z� rۼج�2%Bt�� A? G�,s7�\vAws��\�w�!$8� �Ah2Z'�U��A 5�4�c�$�2
Y��XTN
���� &amp;lt;z�&amp;gt;r�C��OŲt��&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2019 07:47:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371469#M20931</guid>
      <dc:creator>levi12drie</dc:creator>
      <dc:date>2019-10-15T07:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: File upload error code 500</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371597#M20940</link>
      <description>&lt;P&gt;The&amp;nbsp;"content-upload" style endpoints such as /2/files/upload just expect the binary in the request body so you shouldn't have to re-encode the file data after decoding it from base64. In any case, as far as I can tell from our side, the issue here is with parsing the "Dropbox-API-Arg" header, not the body, so that shouldn't be relevant here.&lt;/P&gt;
&lt;P&gt;I see you shared the values you're setting, but can you share the actual raw HTTP request headers as they're being sent?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 16:19:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-upload-error-code-500/m-p/371597#M20940</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-10-15T16:19:22Z</dc:date>
    </item>
  </channel>
</rss>

