我正在使用Laravel创建RESTFUL应用程序,并使用Postman测试该应用程序。当前,PATCH
或者PUT
从Postman发送的带有表单数据的数据是否存在问题。
// Parameter `{testimonial}` will be sent to backend.
Route::post ('testimonials/{testimonial}', 'TestimonialController@update');
// Parameter `{testimonial}` will not be sent to backend (`$request->all()` will be empty) if sent from Postman with form-data.
Route::patch ('testimonials/{testimonial}', 'TestimonialController@update');
Route::put ('testimonials/{testimonial}', 'TestimonialController@update');
Run Code Online (Sandbox Code Playgroud)
$request->all()
可以POST
。$request->all()
会好起来的PATCH
,PUT
和POST
。PUT
并PATCH
使用表单数据,则$request->all()
它将为空(参数将不会发送到后端)。现在,解决方案是POST
用于更新模型。我想知道为什么PATCH
和PUT
Postman的表单数据一起发送时不起作用。