I'm designing a REST API and one if its endpoints is a search. Because the search query contains Personally identifiable information (PII) as a parameter, the endpoint uses POST with the PII parameter in the request body instead of a GET.
So my question is - if the PII parameter is invalid, do I return a 404 or a 422 ?
Example of the API I'm designing - to get all comments by a user .
POST /comments
Request body
{
email: "test-user@gmail.com"
}
Edit: Clarifying my usage of "invalid" : I mean an email id that doesn't exist in our database. I know invalid is not the right term here, "unrecognised" is a better term maybe.