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:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…