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:
and header:
array(1) {["foo"]=> string(3) "bar"}
with jQuery and still an empty array with Postman:array(0) {}
– Dallasfields
andfoo
wont match thus it won't work, Im not sure if it is a typo but make sure they match – meda