<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>application/json Archives - Beshoy Girgis</title>
	<atom:link href="https://beshoy.girgis.us/tag/applicationjson/feed/" rel="self" type="application/rss+xml" />
	<link>https://beshoy.girgis.us/tag/applicationjson/</link>
	<description>Father, husband, son, nerd.</description>
	<lastBuildDate>Sun, 12 Mar 2017 08:03:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>SOLVED: zf2 &#8220;Cannot handle content type &#8216;application/json&#8217; automatically&#8221;</title>
		<link>https://beshoy.girgis.us/2014/10/solved-zf2-handle-content-type-applicationjson-automatically/</link>
					<comments>https://beshoy.girgis.us/2014/10/solved-zf2-handle-content-type-applicationjson-automatically/#comments</comments>
		
		<dc:creator><![CDATA[Beshoy Girgis]]></dc:creator>
		<pubDate>Thu, 30 Oct 2014 08:32:34 +0000</pubDate>
				<category><![CDATA[Nerdy]]></category>
		<category><![CDATA[application/json]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[solved]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zf2]]></category>
		<guid isPermaLink="false">http://beshoy.girgis.us/?p=287</guid>

					<description><![CDATA[I have to admit, this was quite annoying to resolve and didn&#8217;t really have to be an issue in the first place. I&#8217;m using Zend Framework 2.3 and the following was my code: use Zend\Http\Client; use Zend\Http\Request; ... $client = new Client($url); $client -&#62;setHeaders([ 'Content-Type' =&#62; 'application/json', ]) -&#62;setOptions(['sslverifypeer' =&#62; false]) -&#62;setMethod('POST') -&#62;setParameterPost($params); The problem? <a class="read-more" href="https://beshoy.girgis.us/2014/10/solved-zf2-handle-content-type-applicationjson-automatically/">[&#8230;]</a>]]></description>
										<content:encoded><![CDATA[<p>I have to admit, this was quite annoying to resolve and didn&#8217;t really have to be an issue in the first place.</p>
<p>I&#8217;m using Zend Framework 2.3 and the following was my code:</p>
<pre class="brush: php; gutter: true; first-line: 1">use Zend\Http\Client;
use Zend\Http\Request;
...
        $client = new Client($url);
        $client
            -&gt;setHeaders([
                'Content-Type' =&gt; 'application/json',
            ])
            -&gt;setOptions(['sslverifypeer' =&gt; false])
            -&gt;setMethod('POST')
            -&gt;setParameterPost($params);
</pre>
<p>The problem?</p>
<p>I kept getting the following exception thrown: <em><strong>&#8220;Cannot handle content type &#8216;application/json&#8217; automatically&#8221; at vendor/zendframework/zendframework/library/Zend/Http/Client.php line 1219</strong></em>.</p>
<p>I googled and googled and googled and found a BUNCH of different examples on how to do the exact same thing but none of them really resolved this issue for me.  I finally decided to use <a title="Kint" href="http://raveren.github.io/kint/" target="_blank">Kint</a> to debug <strong>$client</strong> and see what methods are available to me.  I saw the <strong>setRawBody</strong> method and thought to myself&#8230; That&#8217;s gotta be it!</p>
<p>The following is the code that works:</p>
<pre class="brush: php; gutter: true; first-line: 1; highlight: [3,12]">use Zend\Http\Client;
use Zend\Http\Request;
use Zend\Json\Json;
...
        $client = new Client($url);
        $client
            -&gt;setHeaders([
                'Content-Type' =&gt; 'application/json',
            ])
            -&gt;setOptions(['sslverifypeer' =&gt; false])
            -&gt;setMethod('POST')
            -&gt;setRawBody(Json::encode($params));
</pre>
<p>I hope this helps!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://beshoy.girgis.us/2014/10/solved-zf2-handle-content-type-applicationjson-automatically/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Object Caching 50/54 objects using disk
Page Caching using disk: enhanced 
Lazy Loading (feed)
Minified using disk
Database Caching 13/24 queries in 0.024 seconds using disk (Request-wide modification query)

Served from: beshoy.girgis.us @ 2026-06-13 00:57:51 by W3 Total Cache
-->