Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter Rest Server fails with PUT method through cURL
    primarykey
    data
    text
    <p>Doing some tests with cURL as client and the CodeIgniter Rest Server. GET, POST and DELETE methods work perfectly but not PUT.</p> <p>Here is my client code for PUT. It's the same as POST (except for CURLOPT_CUSTOMREQUEST):</p> <pre><code>&lt;?php /** * Keys */ include('inc/keys.inc.php'); /** * Data sent */ $content = array( 'name' =&gt; 'syl', 'email' =&gt; 'some@email.it' ); /** * Source */ $source = 'http://localhost/test-rest-api-v2/api_apps/app/id/1'; /** * Init cURL */ $handle = curl_init($source); /** * Headers */ $headers = array( 'X-API-Key: '. $public_key ); /** * Options */ curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); /** * For POST */ curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($handle, CURLOPT_POSTFIELDS, $content); /** * Result */ $result = curl_exec($handle); /** * Close handle */ curl_close($handle); echo $result; ?&gt; </code></pre> <p>I also tried to add to the headers: <code>'Content-Type: application/x-www-form-urlencoded',</code>. Same result.</p> <p>My server code:</p> <pre><code>&lt;?php function app_put() { var_dump($this-&gt;put()); } ?&gt; </code></pre> <p>Result:</p> <blockquote> <p>array(1) { ["------------------------------1f1e080c85df Content-Disposition:_form-data;_name"]=> string(174) ""name" syl ------------------------------1f1e080c85df Content-Disposition: form-data; name="email" some@email.it ------------------------------1f1e080c85df-- " }</p> </blockquote> <p>What's wrong with the PUT method?</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.
 

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