Reputation: 11
I have situation where request syntax and data is proper and the data received from database is not in expected format - its a case of response data issue - In this scenario what is the suitable http status code.
Thought to use 422 - Unprocessable entity - its more on request body validation - please suggest
Thanks
Upvotes: 0
Views: 725
Reputation: 2530
I like to think in this way;
In your case I would still think about the scenario;
So why returned data is not in expected format? Then there is a problem while data is being written do DB like missing validations etc. or some bugs exist.
Upvotes: 1
Reputation: 122
4xx Client Error
The 4xx class of status code is intended for cases in which the client seems to have erred.
So, 4xx codes should be used only for client side errors, in your case, you should use an 5xx error, the best option in your situation is 500
The server encountered an unexpected condition which prevented it from fulfilling the request.
You can see more HTTP Status Codes here
Upvotes: 0
Reputation: 103
Probably Internal Server Error(500) as the error is occurring on the server end. 4XX is only for client-side errors.
Upvotes: 1