Home > Mobile >  Can rest API Response Code for custom error message be 400?
Can rest API Response Code for custom error message be 400?

Time:11-03

In a restful API, what is the correct response code when responding with a custom error message? For example, "Username does not exist"

A colleague is arguing it should be code 400 and not 200

CodePudding user response:

it depends on the case :)

If you are looking for something, it can be even a 404 status code.

If you need succeed response, send 200, otherwise, 400 looks more suitable.

CodePudding user response:

If you have an error message, then the status is definitely not 200. It can be 4xx or 5xx depending on the cause.

  • Related