Laravel: return post request body from Postman in json -
i trying make test work. use rest client, "postman" send post request object laravel. idea request object. don't think getting right result.
in postman, specify adress send to, choose "post", , send this:
{    "url": "http://testingtesting.com" }   in laravel have route adress:
route::post('api/test', 'testcontroller@index');   and controller should return json object. if this:
    class testcontroller extends basecontroller{        public function index(){            $input = input::json()->all();            var_dump($input);            }     }   i array in postman:
array (size=1)   'url' => string 'http://testingtesting.com' (length=18)   that's when @ "preview". if switch "pretty" shows this:
<pre class='xdebug-var-dump' dir='ltr'>     <b>array</b>     <i>(size=1)</i>   'url'      <font color='#888a85'>=></font>     <small>string</small>     <font color='#cc0000'>'http://testing.com'</font>     <i>(length=18)</i> </pre>   but i'm supposed object(stdclass), not array. need do?
i got info here (laracasts forum)get-raw-post-data. seems work with:
class testcontroller extends basecontroller{        public function index(){            $data = json_decode(file_get_contents("php://input"));            var_dump($data);   in postman, results in:
object(stdclass)[144]   public 'url' => string 'http://testingtesting.com' (length=18)   but not sure if recommended way, or why/how works. guess have read more it. if wants add more info, or solutions, feel free!
Comments
Post a Comment