<?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: Dropbox Api throwing error, &amp;quot;request body: could not decode input as JSON&amp;quot; in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Api-throwing-error-quot-request-body-could-not-decode/m-p/297770#M18068</link>
    <description>&lt;P&gt;It looks like you're sending the API parameters in a header with the name "data" in this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;r.setHeader('data','{ "file" : "id:ooT7g_X2tkAAAAAAAAAAEw" ,"actions" : [] }');
&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata" target="_blank"&gt;/2/sharing/get_file_metadata&lt;/A&gt;&amp;nbsp;endpoint is an &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#rpc-endpoints" target="_blank"&gt;"RPC" style endpoint&lt;/A&gt;, so the parameters should be sent as JSON in the request body, not as a header. Update your code to send the JSON in the body instead of a header.&lt;/P&gt;
&lt;P&gt;I can't offer help with programming in Apex itself, but it looks like you may need to use &lt;A href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm#!" target="_self"&gt;the `setBody` method&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Sep 2018 14:45:01 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2018-09-18T14:45:01Z</dc:date>
    <item>
      <title>Dropbox Api throwing error, "request body: could not decode input as JSON"</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Api-throwing-error-quot-request-body-could-not-decode/m-p/297751#M18066</link>
      <description>&lt;P&gt;Whenever I use&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://api.dropboxapi.com/2/sharing/get_file_metadata&amp;nbsp;" target="_blank"&gt;https://api.dropboxapi.com/2/sharing/get_file_metadata&amp;nbsp;&lt;/A&gt;&lt;/STRONG&gt; with apex code or postman, I receive an error message i.e.,&amp;nbsp;&lt;STRONG&gt;Error in call to API function "sharing/get_file_metadata": request body: could not decode input as JSON&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My apex code is as follows:&lt;/P&gt;&lt;PRE&gt;string token = 'https://api.dropboxapi.com/2/sharing/get_file_metadata';
HttpRequest r = new HttpRequest();
r.setEndpoint(token);
r.setHeader('Authorization','Bearer ' +accesstoken);
r.setHeader('Content-Type','application/json');
r.setHeader('data','{ "file" : "id:ooT7g_X2tkAAAAAAAAAAEw" ,"actions" : [] }');
        
r.setMethod('POST');
r.setTimeout(60000);        
Http h1 = new Http();
HttpResponse res1 = h1.send(r);
string resp1 = res1.getBody();
System.debug('MetaData Status :: \n' + resp1);&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 09:10:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Api-throwing-error-quot-request-body-could-not-decode/m-p/297751#M18066</guid>
      <dc:creator>Shobhit_Sharma</dc:creator>
      <dc:date>2019-05-29T09:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Api throwing error, "request body: could not decode input as JSON"</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Api-throwing-error-quot-request-body-could-not-decode/m-p/297770#M18068</link>
      <description>&lt;P&gt;It looks like you're sending the API parameters in a header with the name "data" in this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;r.setHeader('data','{ "file" : "id:ooT7g_X2tkAAAAAAAAAAEw" ,"actions" : [] }');
&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata" target="_blank"&gt;/2/sharing/get_file_metadata&lt;/A&gt;&amp;nbsp;endpoint is an &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#rpc-endpoints" target="_blank"&gt;"RPC" style endpoint&lt;/A&gt;, so the parameters should be sent as JSON in the request body, not as a header. Update your code to send the JSON in the body instead of a header.&lt;/P&gt;
&lt;P&gt;I can't offer help with programming in Apex itself, but it looks like you may need to use &lt;A href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm#!" target="_self"&gt;the `setBody` method&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 14:45:01 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Api-throwing-error-quot-request-body-could-not-decode/m-p/297770#M18068</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-09-18T14:45:01Z</dc:date>
    </item>
  </channel>
</rss>

