Question

This question may be stupid. I want to know if its possible to send a string like {"type":"kissme", "who":"john bennet"} to rest controller as a post request.

I know that post data has to be sent as somekey=somevalue&otherkey=othervalue as body of the request. While receiving we refer to the key to get the data. But how can we send any string without assigning to a key like json data ? If it is possible to send, how to receive ?

Thank you, Abbiya

Was it helpful?

Solution 2

i used file_get_contents('php://input'); while reading in controller. i use the content-type header as application/x-www-form-urlencoded while posting the data

OTHER TIPS

REST implementation for CodeIgniter

You can use any of the following formats too simply by appending /format/json to the end of your URL or passing the correct MIME-type:

  1. xml
  2. json
  3. serialize
  4. php (raw output that can be used in eval)
  5. html
  6. csv

Source: http://philsturgeon.co.uk/blog/2009/06/REST-implementation-for-CodeIgniter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top