<?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: JSON returning NULL from Uploaded file in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424226#M1248</link>
    <description>&lt;P&gt;Thanks for sharing that. That is the error message from the&amp;nbsp;Dropbox API. (Since it's an error about the malformed request, it is just text and not JSON, and so json_decode can't read it. You can check the response's 'Content-Type' to check this programmatically.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, the error message is indicating that the call failed because you did not send valid JSON containing the API call parameters in the request body. &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata" target="_self"&gt;The&amp;nbsp;/2/sharing/get_file_metadata endpoint&lt;/A&gt; is an &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;"RPC" style endpoint&lt;/A&gt;, meaning that it expects the parameters as JSON in the request body. (This is different than&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" target="_self"&gt;/2/files/upload&lt;/A&gt;, which, as a &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;"content-upload" style endpoint&lt;/A&gt;, takes its parameters as JSON in a 'Dropbox-API-Arg' request header.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at your code, I do see that you're attempting to send the&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata" target="_self"&gt;/2/sharing/get_file_metadata&lt;/A&gt; parameters ('file' and 'actions') in a header, which is incorrect. You'll need to update your code for that call to send them in the request body instead.&lt;/P&gt;</description>
    <pubDate>Tue, 26 May 2020 19:33:03 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2020-05-26T19:33:03Z</dc:date>
    <item>
      <title>JSON returning NULL from Uploaded file</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424066#M1241</link>
      <description>&lt;P&gt;I hope you can help. I am trying to get a URL from DropBox using cURL. I am able to upload the file with cURL and retrieve the uploaded file. I have taken the uploaded ID and passed it into the Headers and I get back NULL after I decoded JSON. I am not sure what I am missing. I have attached the code below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;$cheaders = array('Authorization: Bearer xxx',&lt;BR /&gt;'Content-Type: application/octet-stream',&lt;BR /&gt;"Dropbox-API-Arg: {\"path\": \"/Homework/math/Prime_Numbers.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": true}");&lt;/P&gt;
&lt;P&gt;//var_dump($cheaders);&lt;/P&gt;
&lt;P&gt;$ch = curl_init('&lt;A href="https://content.dropboxapi.com/2/files/upload" target="_blank" rel="noopener"&gt;https://content.dropboxapi.com/2/files/upload&lt;/A&gt;');&lt;BR /&gt;curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);&lt;BR /&gt;curl_setopt($ch, CURLOPT_PUT, true);&lt;BR /&gt;curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');&lt;BR /&gt;curl_setopt($ch, CURLOPT_INFILE, $fp);&lt;BR /&gt;curl_setopt($ch, CURLOPT_INFILESIZE, $size);&lt;BR /&gt;curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;$response = curl_exec($ch);&lt;BR /&gt;echo '&amp;lt;pre&amp;gt;';&lt;/P&gt;
&lt;P&gt;var_dump(json_decode($response));&lt;/P&gt;
&lt;P&gt;$obj =json_decode($response);&lt;BR /&gt;print str_replace('id:','',$obj-&amp;gt;{'id'});&lt;/P&gt;
&lt;P&gt;echo '&amp;lt;/pre&amp;gt;';&lt;BR /&gt;fclose($fp);&lt;/P&gt;
&lt;P&gt;$File_ID = $obj-&amp;gt;{'id'};&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;$cheaders2 = array('Authorization: Bearer xxx',&lt;BR /&gt;"Content-Type: application/json" ,&lt;BR /&gt;"{\"file\": \"id:zFe2SHxKbHEAAAAAAAJc-g\",\"actions\": []}"&lt;/P&gt;
&lt;P&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$ch2 = curl_init('&lt;A href="https://api.dropboxapi.com/2/sharing/get_file_metadata" target="_blank" rel="noopener"&gt;https://api.dropboxapi.com/2/sharing/get_file_metadata&lt;/A&gt;');&lt;BR /&gt;curl_setopt($ch2, CURLOPT_HTTPHEADER, $cheaders2);&lt;BR /&gt;curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'POST');&lt;BR /&gt;curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;$response2 = curl_exec($ch2);&lt;BR /&gt;&lt;BR /&gt;var_dump(json_decode($response2));&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2020 07:37:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424066#M1241</guid>
      <dc:creator>BMKN</dc:creator>
      <dc:date>2020-05-27T07:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: JSON returning NULL from Uploaded file</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424183#M1245</link>
      <description>&lt;P&gt;What's the value of&amp;nbsp;$response2 itself, before you try to&amp;nbsp;json_decode it? It's not guarantee to be JSON, e.g., if the called failed. If the call failed, the response body would contain an error. The error could be plain text, not JSON.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should always check the status code to see if the call succeeded or failed, and the 'Content-Type' header of the response to see what type the response is before attempting to parse it.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 17:52:39 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424183#M1245</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-05-26T17:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: JSON returning NULL from Uploaded file</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424208#M1247</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following error&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;&lt;SPAN&gt;string(103) "Error in call to API function "sharing/get_file_metadata": request body: could not decode input as JSON"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 18:56:16 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424208#M1247</guid>
      <dc:creator>BMKN</dc:creator>
      <dc:date>2020-05-26T18:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: JSON returning NULL from Uploaded file</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424226#M1248</link>
      <description>&lt;P&gt;Thanks for sharing that. That is the error message from the&amp;nbsp;Dropbox API. (Since it's an error about the malformed request, it is just text and not JSON, and so json_decode can't read it. You can check the response's 'Content-Type' to check this programmatically.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, the error message is indicating that the call failed because you did not send valid JSON containing the API call parameters in the request body. &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata" target="_self"&gt;The&amp;nbsp;/2/sharing/get_file_metadata endpoint&lt;/A&gt; is an &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;"RPC" style endpoint&lt;/A&gt;, meaning that it expects the parameters as JSON in the request body. (This is different than&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" target="_self"&gt;/2/files/upload&lt;/A&gt;, which, as a &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;"content-upload" style endpoint&lt;/A&gt;, takes its parameters as JSON in a 'Dropbox-API-Arg' request header.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at your code, I do see that you're attempting to send the&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata" target="_self"&gt;/2/sharing/get_file_metadata&lt;/A&gt; parameters ('file' and 'actions') in a header, which is incorrect. You'll need to update your code for that call to send them in the request body instead.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 19:33:03 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/JSON-returning-NULL-from-Uploaded-file/m-p/424226#M1248</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-05-26T19:33:03Z</dc:date>
    </item>
  </channel>
</rss>

