Codeigniter 3.1.8 JSON Post fails - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Codeigniter 3.1.8 JSON Post fails (/showthread.php?tid=70675) |
Codeigniter 3.1.8 JSON Post fails - pigfox - 05-12-2018 Hello Community, I am attempting a JSON POST request to a controller. The header is: Code: [{"key":"Content-Type","value":"application/json"}] Code: {"user":1} Code: public function authorize(){ I am using Postman to make the request. Any clue? RE: Codeigniter 3.1.8 JSON Post fails - jreklund - 05-13-2018 It looks okay to me... Make sure that file_get_contents are activated by trying it on another resource. ->raw_input_stream utilizes that function. PHP Code: <?php Postman settings: Content-Type: application/json X-Requested-With: xmlhttprequest RE: Codeigniter 3.1.8 JSON Post fails - pigfox - 05-13-2018 According to my host: I can confirm that file_get_contents and allow_url_fopen are enabled. Then I tried your suggestion. Code: public function authorize(){ I am also using the headers you suggested, see screen shot. Any other ideas? RE: Codeigniter 3.1.8 JSON Post fails - jreklund - 05-13-2018 Have you tried grabbing another source/website with file_get_contents() to confirm it's actually activated? Have you tried making a POST without https? In case your Cross-Origin Resource Sharing (CORS) are set wrong. Don't know if this actually apply to Postman thought. Do you have the latest Codeigniter? Do you have the latest PHP version? (7.1 or 7.2) RE: Codeigniter 3.1.8 JSON Post fails - pigfox - 05-13-2018 (05-13-2018, 12:39 PM)jreklund Wrote: Have you tried grabbing another source/website with file_get_contents() to confirm it's actually activated? My PHP version is .7.0.28 Codeigniter version is 3.1.8 The following code snippet works. PHP Code: <? Posting {"user":1} gives me: array(1) { ["user"]=> int(1) } |