Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to set Content-type: application/json in yii extension?
    primarykey
    data
    text
    <p><strong>I am using yii extension for rest API.But I am not able to set content-type in header information.</strong></p> <p><a href="http://www.yiiframework.com/extension/yii-curl/" rel="nofollow">using this YII extension</a></p> <p>Please,provide solution of it?</p> <p>My REST file test.php code:</p> <pre><code>&lt;?php echo "In rest api"; print_r($_SERVER); ?&gt; </code></pre> <p>I called it from Yii CURL:</p> <pre><code>echo $output = Yii::app()-&gt;curl-&gt;setOption(CURLOPT_HTTPHEADER, array('CONTENT_TYPE: application/json')) -&gt;post("localhost/test.php"); </code></pre> <p>I got following output:</p> <p>HTTP/1.1 100 Continue</p> <pre><code>HTTP/1.1 200 OK Date: Wed, 13 Nov 2013 18:14:10 GMT Server: Apache/2.2.21 (Win32) PHP/5.3.8 X-Powered-By: PHP/5.3.8 Content-Length: 311 Content-Type: text/html In rest apiArray ( [HTTP_USER_AGENT] =&gt; Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20110619 Firefox/5.0 [HTTP_HOST] =&gt; localhost [HTTP_ACCEPT] =&gt; */* [CONTENT_LENGTH] =&gt; 143 [HTTP_EXPECT] =&gt; 100-continue [CONTENT_TYPE] =&gt; multipart/form-data; boundary=----------------------------f0f331e79d34 [PATH] =&gt; C:\Windows\system32;C:\Windows;C:\Windows\system32\Wbem;C:\Program Files\Dell\DW WLAN Card;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\cvsnt; [SystemRoot] =&gt; C:\Windows [COMSPEC] =&gt; C:\Windows\system32\cmd.exe [PATHEXT] =&gt; .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [WINDIR] =&gt; C:\Windows [SERVER_SIGNATURE] =&gt; [SERVER_SOFTWARE] =&gt; Apache/2.2.21 (Win32) PHP/5.3.8 [SERVER_NAME] =&gt; localhost [SERVER_ADDR] =&gt; 127.0.0.1 [SERVER_PORT] =&gt; 80 [REMOTE_ADDR] =&gt; 127.0.0.1 [DOCUMENT_ROOT] =&gt; C:/wamp/www/ [SERVER_ADMIN] =&gt; admin@localhost [SCRIPT_FILENAME] =&gt; C:/wamp/www/testforget.php [REMOTE_PORT] =&gt; 1287 [GATEWAY_INTERFACE] =&gt; CGI/1.1 [SERVER_PROTOCOL] =&gt; HTTP/1.1 [REQUEST_METHOD] =&gt; POST [QUERY_STRING] =&gt; [REQUEST_URI] =&gt; /testforget.php [SCRIPT_NAME] =&gt; /testforget.php [PHP_SELF] =&gt; /testforget.php [REQUEST_TIME] =&gt; 1384365808 </code></pre> <p>)</p> <p>I got </p> <pre><code>[CONTENT_TYPE] =&gt; multipart/form-data; </code></pre> <p>why I got content_type this,But it should get [CONTENT_TYPE] => application/json as I set it in my request?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload