I am using Laravel to create a RESTFUL application and I test the application with Postman. Currently, there is an issue for PATCH
or PUT
if the data sent from Postman with form-data.
// 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');
- Using form-data,
$request->all()
will be okay for POST
.
- Using x-www-form-urlencoded,
$request->all()
will be okay for PATCH
, PUT
, and POST
.
- However, if I am sending
PUT
and PATCH
with form-data from Postman, the $request->all()
will be empty (the parameters will not be sent to backend).
Right now the solution is to use POST
for updating a model. I want to know why PATCH
and PUT
is not working when sent with form-data from Postman.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…