2016-06-26 4 views
0

Phil Sturgeon用のRESTライブラリを使用して、 GETとPOST要求が正常に動作するREST APIを開発しました。 PUTリクエストで渡されたパラメータにアクセスしようとすると、 nullを取得します。私はます$ this->は、(ID)またはます$ this->ポスト(ID)が正常に動作されておらず、取得理由を理解しない POSTMAN PUT Call screenshotCodeigniter Rest API:Put要求が渡されません。

class ApiItems extends REST_Controller 
{ 
    function __construct() { 
    // 
    } 

    public function items_get(){ // //} 
    public function items_post(){ // //} 

    public function items_put() 
    {  
     if(!$this->put('id'))   //My issue : I can't get the id here 
     { 
      $this->response(array('error' => 'Item id is required'), 400); 
     } 


     $data = array(
      'id' => $this->put('id'), 
      'code'=> $this->put('code'), 
      'name' => $this->put('name'), 
      'quantity' => $this->put('quantity') 
     ); 

     $this->item_model->update_item($this->put('id'), $data); 
     $message = array('success' => $id.' Updated!'); 
     $this->response($message, 200); 
    } 
} 

私はPOSTMANを使用して、それをテストし、私はこれを取得します$ this-> put(id)の場合?

+0

のフォーム・データをチェックしそれが働いて、私は、充填時に愚かなミスをやりましたPOSTMANのパラメータ、x-www-form-url-encodedの代わりにform-dataをチェックしました – eamon

答えて

1

それは働いて、私はPOSTMANでパラメータを充填する際の愚かなミスをやった、私の代わりに、X-WWW-フォームURLエンコード

関連する問題