【发布时间】:2020-05-22 16:15:31
【问题描述】:
我有一个 REST POST 请求,格式如下:
{
"data" : {
"type" : "studies",
"attributes" : {
"age": "9999",
"name": "XYZ"
}
}
}
我希望能够上传带有请求的文件。所以我的请求正文看起来像这张图片。
问题是,在我的控制器中,我无法检测到任何东西。
if($request->has('data.attributes.name')) $name = $request->input('data.attributes.name')
if($request->has('data.attributes.age')) $name = $request->input('data.attributes.age')
if($request->hasFile('data.attributes.file')){
//Upload the file
}
很遗憾,我的控制器无法检测到这些属性。我应该如何在 Postman 中输入它们?
【问题讨论】:
-
您在 Postman 中收到的状态是 419 还是 200?
标签: laravel rest post controller postman