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 forPOST
. - Using x-www-form-urlencoded,
$request->all()
will be okay forPATCH
,PUT
, andPOST
. - However, if I am sending
PUT
andPATCH
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.
PATCH
andPUT
request though. – Prostomium