Reputation: 115
I want to use custom identifier in a custom action without using {id} like this .
@ApiResource(
itemOperations={
"FORGOT-PASSWORD"={
"method"="PUT",
"path"="/users/{forgotPasswordToken}/forgot-password",
"controller"="App\Controller\ForgotPasswordController",
"defaults"={"identifiedBy"="forgotPasswordToken"}
}
}
)
But i still have the same error with "Invalid identifier value or configuration" .
Any issue please ?
Upvotes: 1
Views: 4570
Reputation: 1201
It's because Api Platform have a Read listener that try to retrieve the entity link to your item operation.
For your custom action you don't have identifier in your path like {id}
to identify your resource, so the solution is to desactive the read listener with something like this :
@ApiResource(
itemOperations={
"FORGOT-PASSWORD"={
"method"="PUT",
"path"="/users/{forgotPasswordToken}/forgot-password",
"controller"="App\Controller\ForgotPasswordController",
"defaults"={"identifiedBy"="forgotPasswordToken"},
"read"=false
}
}
)
Upvotes: 4