Send POST data via raw json with postman

Dallas picture Dallas · Aug 18, 2016 · Viewed 309.3k times · Source

I've got Postman (the one that doesn't open in Chrome) and I'm trying to do a POST request using raw json.

In the Body tab I have "raw" selected and "JSON (application/json)" with this body:

{
    "foo": "bar"
}

For the header I have 1, Content-Type: application/json

On the PHP side I'm just doing print_r($_POST); for now, and I'm getting an empty array.


If I use jQuery and do:

$.ajax({
    "type": "POST",
    "url": "/rest/index.php",
    "data": {
        "foo": "bar"
    }
}).done(function (d) {
    console.log(d);
});

I'm getting as expected:

Array
(
    [foo] => bar
)

So why isn't it working with Postman?


Postman screenshots:

enter image description here

and header:

enter image description here

Answer

Itachi picture Itachi · Jan 29, 2019

Just check JSON option from the drop down next to binary; when you click raw. This should do

skill synon pass json to postman