You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
I've tried to create a custom endpoint for retrieving the user details for the current authenticated user. It took me several hours to figure out, why it doesn't worked as seen on the documentation. I tried this even in YAML, as even in the PHP-Attribute Version. When using POST-Attribute, the route is correct and the Controller is responding with the correct data from the method. When i try to access the same (as required) with a GET-Attribute, i get always 404 error. The code examples are shown below in additional context.
How to reproduce
Not working example with GET-Collection
#[GetCollection(
controller: UserController::class,
openapi: newOperation(
summary: 'Get the current user details',
description: 'Get the current user details',
requestBody: newRequestBody(),
),
security: 'is_granted("ROLE_USER")',
name: 'app_user_current'
)]
Working example with POST
Exactly the same, only change has been made in the first line
#[Post(
uriTemplate: '/api/users/current',
controller: UserController::class,
openapi: newOperation(
summary: 'Get the current user details',
description: 'Get the current user details',
requestBody: newRequestBody(),
),
security: 'is_granted("ROLE_USER")',
name: 'app_user_current'
)]
The SwaggerUI is showing the route in both variants, but the GET-Response is always 404 not found. The Symfony router debug command is showing these routes also in both variants.
The text was updated successfully, but these errors were encountered:
cloudmaker97
changed the title
Custom Controller only works on POST, not on GET-Collection
Custom Controller via POST accessible, not via GET-Collection
Mar 29, 2024
API Platform version(s) affected: 3.2
Description
I've tried to create a custom endpoint for retrieving the user details for the current authenticated user. It took me several hours to figure out, why it doesn't worked as seen on the documentation. I tried this even in YAML, as even in the PHP-Attribute Version. When using POST-Attribute, the route is correct and the Controller is responding with the correct data from the method. When i try to access the same (as required) with a GET-Attribute, i get always 404 error. The code examples are shown below in additional context.
How to reproduce
Not working example with GET-Collection
Working example with POST
Exactly the same, only change has been made in the first line
Code from the Controller
Additional Context
The SwaggerUI is showing the route in both variants, but the GET-Response is always 404 not found. The Symfony router debug command is showing these routes also in both variants.
Error-Response when requesting via GET-Request
Thank you for your amazing work! ❤️
The text was updated successfully, but these errors were encountered: