<?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 Bad HTTP &amp;quot;Content-Type&amp;quot; header in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400713#M21934</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am writing a simple app that creates some folders when we add a new client to our systems.&lt;/P&gt;
&lt;P&gt;I keep getting an error:&lt;/P&gt;
&lt;PRE&gt;Error in call to API function "files/create_folder_batch": Bad HTTP "Content-Type" header: "application/json; boundary=------------------------0e03e86aa71fa792". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack".&lt;/PRE&gt;
&lt;P&gt;Here is the code that I am using:&lt;/P&gt;
&lt;PRE&gt;function create_folders() {
	$ch = curl_init();
	$folders = array(
	    "/B - Client Folders/" . $folder_name, 
	    "/B - Client Folders/" . $folder_name . "/Logo", 
	    "/B - Client Folders/" . $folder_name . "/Photos", 
	    "/B - Client Folders/" . $folder_name . "/Graphics"
	    );

	$params = array(
	    $folders, 
	    '"autorename":false', 
	    '"force_async":false');

	curl_setopt($ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/files/create_folder_batch');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
	
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	    'Authorization: Bearer &amp;lt;key&amp;gt;',
	    'Dropbox-Api-Path-Root: {".tag": "namespace_id", "namespace_id": "&amp;lt;nsid&amp;gt;"}',
	    'Content-Type: application/json'));

	$result = curl_exec($ch);
	if (curl_errno($ch)) {
		echo 'Error:' . curl_error($ch);
	} else {echo $result;}
	curl_close($ch);
}&lt;/PRE&gt;
&lt;P&gt;I don't understand why "&lt;SPAN&gt;; boundary=------------------------0e03e86aa71fa792" is being added to "application/json".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Thanks for your help in advance.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Mar 2020 07:33:39 GMT</pubDate>
    <dc:creator>heisenberg41</dc:creator>
    <dc:date>2020-03-05T07:33:39Z</dc:date>
    <item>
      <title>Bad HTTP "Content-Type" header</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400713#M21934</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am writing a simple app that creates some folders when we add a new client to our systems.&lt;/P&gt;
&lt;P&gt;I keep getting an error:&lt;/P&gt;
&lt;PRE&gt;Error in call to API function "files/create_folder_batch": Bad HTTP "Content-Type" header: "application/json; boundary=------------------------0e03e86aa71fa792". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack".&lt;/PRE&gt;
&lt;P&gt;Here is the code that I am using:&lt;/P&gt;
&lt;PRE&gt;function create_folders() {
	$ch = curl_init();
	$folders = array(
	    "/B - Client Folders/" . $folder_name, 
	    "/B - Client Folders/" . $folder_name . "/Logo", 
	    "/B - Client Folders/" . $folder_name . "/Photos", 
	    "/B - Client Folders/" . $folder_name . "/Graphics"
	    );

	$params = array(
	    $folders, 
	    '"autorename":false', 
	    '"force_async":false');

	curl_setopt($ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/files/create_folder_batch');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
	
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	    'Authorization: Bearer &amp;lt;key&amp;gt;',
	    'Dropbox-Api-Path-Root: {".tag": "namespace_id", "namespace_id": "&amp;lt;nsid&amp;gt;"}',
	    'Content-Type: application/json'));

	$result = curl_exec($ch);
	if (curl_errno($ch)) {
		echo 'Error:' . curl_error($ch);
	} else {echo $result;}
	curl_close($ch);
}&lt;/PRE&gt;
&lt;P&gt;I don't understand why "&lt;SPAN&gt;; boundary=------------------------0e03e86aa71fa792" is being added to "application/json".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Thanks for your help in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 07:33:39 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400713#M21934</guid>
      <dc:creator>heisenberg41</dc:creator>
      <dc:date>2020-03-05T07:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Bad HTTP "Content-Type" header</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400747#M21939</link>
      <description>&lt;P&gt;It looks like you're just passing along a native object as the API call parameters, and curl is then applying the multi-part Content-Type. You should send up the parameters as&amp;nbsp;JSON.&lt;/P&gt;
&lt;P&gt;You can build your parameters as JSON like:&lt;/P&gt;
&lt;PRE&gt;$params = json_encode(array(
    'paths'=&amp;gt; $folders,
    'autorename'=&amp;gt; false,
    'force_async'=&amp;gt; false));&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Mar 2020 00:12:24 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400747#M21939</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-03-05T00:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Bad HTTP "Content-Type" header</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400913#M21946</link>
      <description>&lt;P&gt;Thank you Greg! That worked.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Biggest noob question of all.&amp;nbsp; How did you know it had to be JSON encoded?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:06:04 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400913#M21946</guid>
      <dc:creator>heisenberg41</dc:creator>
      <dc:date>2020-03-05T18:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Bad HTTP "Content-Type" header</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400919#M21948</link>
      <description>&lt;P&gt;Great, thanks for confirming that.&lt;/P&gt;
&lt;P&gt;All&amp;nbsp;Dropbox API v2 endpoints (except OAuth endpoints) expect the parameters as JSON, though there are some different ways of sending them. You can find information about each one in &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation" target="_self"&gt;the documentation&lt;/A&gt;. For example, &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder_batch" target="_self"&gt;the&amp;nbsp;/2/files/create_folder_batch endpoint&lt;/A&gt; uses the "RPC" &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;format&lt;/A&gt;, so it expects "JSON in the request body and return results as JSON in the response body".&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:27:11 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/400919#M21948</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-03-05T18:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Bad HTTP "Content-Type" header</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/472318#M23991</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Error in call to API function "sharing/create_shared_link_with_settings": Bad HTTP "Content-Type" header: "application/json{\"path\":\"\\/1uawro.jpg\",\"settings\":{\"requested_visibility\":\"public\",\"audience\":\"public\",\"access\":\"viewer\"}}". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$share_link = array("path"=&amp;gt; $path, "settings"=&amp;gt; array("requested_visibility"=&amp;gt; "public", "audience"=&amp;gt; "public", "access"=&amp;gt; "viewer"));&lt;BR /&gt;$share_link_url = "&lt;A href="https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings" target="_blank"&gt;https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings&lt;/A&gt;";&lt;BR /&gt;$headers = array('Authorization: Bearer '. $token,&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;'Content-Type: application/json'.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;json_encode($share_link)&lt;/FONT&gt;&lt;BR /&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i was encoded but not work for me.plz advice&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 21:03:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/472318#M23991</guid>
      <dc:creator>eranga119</dc:creator>
      <dc:date>2020-11-22T21:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Bad HTTP "Content-Type" header</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/472331#M23992</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1377450"&gt;@eranga119&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Why are you passing the body part (in your post: $share_link) in header part? The particular error message denote the sticking the body to the "Content-Type" header, which is NOT correct of course. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 23:41:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/472331#M23992</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2020-11-22T23:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Bad HTTP "Content-Type" header</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/472524#M23996</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1377450"&gt;@eranga119&lt;/a&gt;&amp;nbsp;This error message indicates that instead of just sending the expected "application/json" value in your "Content-Type" header, you're instead sending that plus the JSON string for the API call parameters, as Здравко said. That JSON should be sent in the request body, not a header.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code you shared does seem to show you are incorrectly appending those parameters to your "Content-Type" header value, so you should fix your code to put that in the request body instead.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 15:00:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/472524#M23996</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-11-23T15:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Bad HTTP "Content-Type" header</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/472530#M23999</link>
      <description>&lt;P&gt;@greg-DB thank you for quick responce.i was fix my code and it's work perfectly now. you are abslutly correct.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 15:09:06 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Bad-HTTP-quot-Content-Type-quot-header/m-p/472530#M23999</guid>
      <dc:creator>eranga119</dc:creator>
      <dc:date>2020-11-23T15:09:06Z</dc:date>
    </item>
  </channel>
</rss>

