0

I am new for codeigniter and I am using Phil Sturgeon’s REST server for "post" type of web service. althiugh my 'get' type web service is working perfectly. Below is my controller code for post web service.

require(APPPATH.'libraries/REST_Controller.php');

class json extends REST_Controller {

public function __construct()   {

    parent::__construct();

}

public function data_post() {

    $user = array(
        'id' => $params['id']
    );

    $this->response(array('status'=>'success'), 200);

}

}

and i amd using rest add on to check web services working or not but i am getting below error.

Fatal error: Uncaught exception 'Exception' with message 'Format class does not support conversion from "php".' in /home/magnetic/public_html/touch/order-form/application/libraries/Format.php:51 Stack trace: #0 /home/magnetic/public_html/touch/order-form/application/libraries/Format.php(31): Format->__construct('{"id": "restCli...', 'php') #1 /home/magnetic/public_html/touch/order-form/application/libraries/REST_Controller.php(247): Format->factory('{"id": "restCli...', 'php') #2 /home/magnetic/public_html/touch/order-form/application/controllers/json.php(6): REST_Controller->__construct() #3 /home/magnetic/public_html/touch/order-form/system/core/CodeIgniter.php(308): json->__construct() #4 /home/magnetic/public_html/touch/order-form/index.php(202): require_once('/home/magnetic/...') #5 {main} thrown in /home/magnetic/public_html/touch/order-form/application/libraries/Format.php on line 51

http://awesomescreenshot.com/0cd38frz01 is screenshot of rest addon error

Please let me know what else i need to do if anything remaining in my code and please let me know the whole process of using rest server for 'post' web services. Thanks in advance

1 Answers1

0

In the body of the RESTClient, try sending:

id=restClient%20Test

instead of

{"id": "restCliente Test"}
  • thanks for your reply man but this is not the issue. although i have tried it. – Sunil Kumar Jul 31 '14 at 06:36
  • 1
    @RobertMiles Have you checked if the parameter `Content-type: application/x-www-form-urlencoded` is being sent in the request header? Can this be .. – Jansen Felipe Aug 05 '14 at 20:04
  • how? please let me know by example – Sunil Kumar Aug 06 '14 at 05:58
  • In RESTClient, click on "Headers > Custom header". Follow printscreen: [http://snag.gy/to3Nh.jpg](http://snag.gy/to3Nh.jpg) – Jansen Felipe Aug 06 '14 at 11:51
  • but this is working for single value what if i have to send multiple values like id, email, etc. I used {"id":1;"email":"xyz@abc.com"} this is returning false instead of values. Do i need to change header or anything else. please let me know and thanks in advance. – Sunil Kumar Aug 07 '14 at 06:33