I am using laravel 9 and Passport, I can't update data neither PUT nor PATCH method is working. Here is my route api.php
Route::group(['middleware' => 'auth:api'], function() {
Route::get('logout', [AuthController::class,'logout']);
Route::resource('user',UserController::class);
Route::resource('/admin/post', PostController::class);
});
all another protected routes is ok, but when i Put or patch to localhost:8000 the request is always blank even the id is correct, for example in localhost:8000/api/admin/post/1 and in PostController update(Request $request,$id) when i dd($request, $id) will be "null",5
my request
curl --request PATCH \
--url http://localhost:8000/api/admin/post/5 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiZDU3MjhjZjZlMGVjMTVmMmQ1ZTJhYzFkMDU3MGQ0YzdhMDBlZmFhMDBjNWY2NDI1Yjk5MjY5YTFiZDNjNDE3Y2MxMmJmMjcwY2FkMjI0ZWUiLCJpYXQiOjE2NjA1MDMxNzYuNTUxMDk2LCJuYmYiOjE2NjA1MDMxNzYuNTUxMDk5LCJleHAiOjE2OTIwMzkxNzYuNTI5MTI0LCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.VvYis4iH3pUNLp1Zz4UOC9lQ6h4Gpi4xA44BA4rd7iQe-Z5IowjEwMkkYceuq8sZJAnbp9xh-li_zYXq-tEFakN9gKm3-hxr6gE8sqRj4WCSnVOu_KoqSKWX_FVlDW_IEhIfzGQdeIIRDgXuyz5E6dXxpqqtEsOiRY0KNKxjKRIG7gz0D0CO4lzTRkbly8nCG-CeBBYYS_jXonG4comxPk6eWnbDkw4yNBtdHQ9HK-E92PixbeMW13JPZ5Iiu-JmhLfOSSLrUqa_bJNW7WmbPTsBiyNZyRZ8kEYVbeVvKpMl37HoIDvJnvS9iydLW20Zb7KQkFEoI7bFS7jJdySXXPWIHqnqnFv4u0P6ko1rlLt5PCzyitIX_TdxvXYSaxfUQJMf9SPCG2P0Juxhhcsym8ob70VskVIwSCIGgvbi96JNKBhIhR9bJUX6eEhEOWeWB7jBRaquevTtpTBAm2qbGJPv4Crx2DksFHIuBOxCD33F-MFOSxvK5K2t-NTOofic2cOziYLSgVSrPYy2HHdnriWoAvZynUM2hDYKntzG8x3VYqswYkXwONtyQZpGAGBnDcZq9Fa2YDV6Poqwy_RdeCY6wlyF_1RI6unOgpDYm6GtTE4n51jijNx_kTm9s7F48CHva4aGNATQPoRYuVSWdOZo5VcgkKMfI04np4fQTeY' \
--header 'Content-Type: multipart/form-data' \
--form 'title=mau diganti' \
--form 'description=Sebuah tutorial untuk membunuh polisi' \
--form 'content=hehe' \
--form 'tags=[1,2]' \
--form 'categories=[1]' \
--form 'thumbnail=@C:\Users\Bloop\Pictures\anak kak risti.jpg' \
what is wrong?
CodePudding user response:
Add _method=PUT
or _method=PATCH
in your body, and use curl --request POST
instead.