Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

OfficialEllaris's avatar

Laravel PUT request to API via Postman not working.

routes/api.php

// UserController Routes (Requires authentication)
Route::middleware('auth:sanctum')->controller(UserController::class)->group(function () {
    Route::get('/profile', 'getProfile');
    Route::put('/profile', 'updateProfile');
});

Controllers/UserController.php

I'm currently testing this endpoint with Postman form-data. On sending the request, the fields are not being updated. So I tried logging the request fields but it returned an empty array. After noticing that, I switched the method to a POST method both on Postman and in the api.php file. To my surprise, it returned the fields. What could be the cause of this behavior. Please am I doing something wrong here.

PS: before returning the request, I removed ": JsonResponse" type hint from the updateProfile method.

1 like
9 replies
OfficialEllaris's avatar

@vincent15000 CSRF tokens are unnecessary for API authentication when using Laravel Sanctum with bearer tokens. Since bearer tokens handle authentication, CSRF protection is not required in this setup.

2 likes
Sergiu17's avatar
Sergiu17
Best Answer
Level 60
Route::put('/profile', 'updateProfile');`

You can fake it, send a POST request to api/profile and add one more attribute _method which will be set to PUT.

Edit, not fake it, but this is actually how the framework works.

2 likes
Sergiu17's avatar

@vincent15000 the authentication works as expected, he managed to receive the field by using POST request, the issue is when using PUT

2 likes

Please or to participate in this conversation.