作者:我家在波力牧场 | 来源:互联网 | 2023-07-08 23:41
I've got Postman (the one that doesn't open in Chrome) and I'm trying to do a POST request using raw json.
我有了Postman(在Chrome中没有打开的那个),我正在尝试使用原始json做一个POST请求。
In the Body tab I have "raw" selected and "JSON (application/json)" with this body:
在Body选项卡中,我选择了“raw”和“JSON (application/ JSON)”。
{
"foo": "bar"
}
For the header I have 1, Content-Type: application/json
对于header,我有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.
在PHP方面,我只做print_r($_POST);现在,我得到一个空数组。
If I use jQuery and do:
如果我使用jQuery并做:
$.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:
标题:
3 个解决方案