Reputation: 1082
I have an endpoint that receives a registration form body to validate in the backend:
POST .../api/v1/validate-user
Then endpoint will response something like this:
200 OK
{
"valid": false,
"message": "The registration cannot continue."
}
The validation is done in the backend because it uses sensitive data in the server to validate the user. This process cannot be included in the actual "save" endpoint and properly accept/reject the request because of reasons I have no control of.
My question is: Is this a poor design because the endpoint responds 200 OK
even if the validation does not yield a "good" or "positive" result?
... or is this OK because the server understood and processed the request properly and responded accordingly?
Upvotes: 1
Views: 311
Reputation: 13682
That's perfectly fine. Conceptually, you're requesting a resource that tells you if the user is valid or not. You're getting a response that tells you if the user is valid or not. So your request went through just fine, and so a 200
-level response is appropriate.
Upvotes: 1