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
How to send json string to phil sturgeon's Rest Controller?
-
04-06-2022 - |
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
Solution 2
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:
- xml
- json
- serialize
- php (raw output that can be used in eval)
- html
- csv
Source: http://philsturgeon.co.uk/blog/2009/06/REST-implementation-for-CodeIgniter
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow