【发布时间】:2018-08-02 04:48:50
【问题描述】:
我正在使用 Postman 和 Insomnia 等应用程序发送 API 请求。
我可以发送一个带有表单数据的 Body 的 POST 请求,所以它看起来像
parameters:[{"fullname" : "John Smith", "username" : "jsmith", "email" : "jsmith@example.com", "password" : "s348nfdf"},{"fullname" : "Janine Smith", "username" : "jsmith1", "email" : "jsmith1@example.com", "password" : "ddfgret567"}]↵
一切正常,我可以从后端的请求中获取参数。
但是,如果我将请求更改为 PUT,则正文(上述参数)不在请求中($_REQUEST)。请求本身是成功的,没有错误代码。
我也尝试过 x-www-form-urlencoded 和原始 JSON。
为什么缺少正文(参数)?
【问题讨论】:
-
根据文档,$_REQUEST 仅包含来自 GET、POST 和 COOKIE 的项目。如果你想要 PUT 的正文,请使用
php://input