我有一个REST POST请求,该请求应采用以下格式:
for tablenum in range(number_of_tables):
tablename = docu.add_table(rows=number_of_rows, cols=number_of_cols)
for r, rowiteration in enumerate(tablename.rows):
for c, cells in enumerate(rowiteration.cells):
exclude = [docu.tables[num].cell(r,c).text for num in range(tablenum)]
cells.text = random.choice([s for s in list if s not in exclude])
我希望能够随请求上传文件。所以我的请求正文看起来像这张图片。
问题是,在我的控制器中,我无法检测到任何东西。
{
"data" : {
"type" : "studies",
"attributes" : {
"age": "9999",
"name": "XYZ"
}
}
}
不幸的是,我的控制器无法检测到这些属性。我应该如何在Postman中输入它们?
答案 0 :(得分:1)
点距将转换为_
。因此,您可以:
{
"data_attributes_file": "file",
"data_attributes_name": "XYZ",
"data_attributes_age": "999"
}
$request->has('data_attributes_file')
$request->has('data_attributes_name')
$request->has('data_attributes_age')
如果您仍然有空白页或错误519
问题,则需要将CSRF
令牌放入Cookie或其他令牌中。
app / Http / Middleware / VerifyCsrfToken
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
*/
protected $addHttpCookie = true;
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'*',
];
}
答案 1 :(得分:0)