<?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: get_temporary_link and could not decode input as JSON in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/get-temporary-link-and-could-not-decode-input-as-JSON/m-p/364985#M20718</link>
    <description>&lt;P&gt;Greg&lt;/P&gt;&lt;P&gt;Thank you very much for support. Now works fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$getlink_url = 'https://api.dropboxapi.com/2/files/get_temporary_link'; 

$getlink_headers = array    (   'Authorization: Bearer '. $token,
                                            'Content-Type: application/json'
                                        );
$ch1 = curl_init($getlink_url);


$parameters = json_encode(
                array (
                "path"=&amp;gt;"/file_storage/some_file.zip"
                )
            );
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch1, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $getlink_headers);
            
               
            
$response2 = curl_exec($ch1);
curl_close($ch1);
error_log($response2);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best, Michal&lt;/P&gt;</description>
    <pubDate>Fri, 13 Sep 2019 18:58:57 GMT</pubDate>
    <dc:creator>jurgenatore</dc:creator>
    <dc:date>2019-09-13T18:58:57Z</dc:date>
    <item>
      <title>get_temporary_link and could not decode input as JSON</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/get-temporary-link-and-could-not-decode-input-as-JSON/m-p/364979#M20716</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;
&lt;P&gt;I'm trying to get a temporary link for file with using get_temporary_link from file_properties with below listed PHP code:&lt;/P&gt;
&lt;PRE&gt;$getlink_url = 'https://api.dropboxapi.com/2/files/get_temporary_link'; 

$getlink_headers = array    (   'Authorization: Bearer '. $token,
                                            'Content-Type: application/json',
                                            'data: '.
                                            json_encode(
                                                array (
                                                "path"=&amp;gt;"/file_storage/some_file.zip"
                                                )
                                            )

                                        );
            $ch1 = curl_init($getlink_url);
            curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "POST");
            curl_setopt($ch1, CURLOPT_HTTPHEADER, $getlink_headers);
            
               
            
            $response2 = curl_exec($ch1);
            curl_close($ch1);
            error_log($response2);&lt;/PRE&gt;
&lt;P&gt;But i receive an error:&lt;/P&gt;
&lt;P&gt;[php7:notice] [pid 25434] [client ::1:40512] Error in call to API function "files/get_temporary_link": request body: could not decode input as JSON, referer: http://localhost/DropTest.html&lt;BR /&gt;&lt;BR /&gt;Could you please let me know what i'm doing wrong. I found solutions for other languages but not for PHP.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you in advance for support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Michal&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 19:00:36 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/get-temporary-link-and-could-not-decode-input-as-JSON/m-p/364979#M20716</guid>
      <dc:creator>jurgenatore</dc:creator>
      <dc:date>2019-09-16T19:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: get_temporary_link and could not decode input as JSON</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/get-temporary-link-and-could-not-decode-input-as-JSON/m-p/364981#M20717</link>
      <description>&lt;P&gt;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link" target="_self"&gt;The /2/files/get_temporary_link endpoint&lt;/A&gt; is an &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;RPC-style&lt;/A&gt; endpoint, so it expects the API call parameters as JSON in the request body.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the code you shared, you're actually sending the parameters in a header named 'data'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need to fix your code to send them in the request body, like:&lt;/P&gt;
&lt;PRE&gt;$parameters = json_encode(
                    array (
                    "path"=&amp;gt;"/file_storage/some_file.zip"
                    )
                );&lt;/PRE&gt;
&lt;PRE&gt;curl_setopt($ch1, CURLOPT_POSTFIELDS, $parameters);&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2019 18:34:18 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/get-temporary-link-and-could-not-decode-input-as-JSON/m-p/364981#M20717</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-09-13T18:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: get_temporary_link and could not decode input as JSON</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/get-temporary-link-and-could-not-decode-input-as-JSON/m-p/364985#M20718</link>
      <description>&lt;P&gt;Greg&lt;/P&gt;&lt;P&gt;Thank you very much for support. Now works fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$getlink_url = 'https://api.dropboxapi.com/2/files/get_temporary_link'; 

$getlink_headers = array    (   'Authorization: Bearer '. $token,
                                            'Content-Type: application/json'
                                        );
$ch1 = curl_init($getlink_url);


$parameters = json_encode(
                array (
                "path"=&amp;gt;"/file_storage/some_file.zip"
                )
            );
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch1, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $getlink_headers);
            
               
            
$response2 = curl_exec($ch1);
curl_close($ch1);
error_log($response2);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best, Michal&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 18:58:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/get-temporary-link-and-could-not-decode-input-as-JSON/m-p/364985#M20718</guid>
      <dc:creator>jurgenatore</dc:creator>
      <dc:date>2019-09-13T18:58:57Z</dc:date>
    </item>
  </channel>
</rss>

