Search code examples
resthttphttp-status-code-404

What will be the http status code for data save failed


Sent 3 data with post request. For some reason it couldn't be saved on database table. Such as, foreign key constraint failed. then what will be the http status code?


Solution

  • 500-599 is reserved for server errors in HTTP response status codes.

    500 specifically is for Internal Server Error, which you could throw in the event that a validation error occured.

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses