7

I am unsure what http status code to return when a customer calls my API, but the requested action cannot be completed for reasons that the customer can fix.

In this case, the http request itself may be fine, but it will not succeed until the customer logs into the front end and updates their configuration. (I will return a body with some informative message to indicate this.)

Is 412 - Precondition Failed - appropriate for this case?

1 Answer 1

7

412 Precondition Failed

The server does not meet one of the preconditions that the requester put on the request.

This statuscode has a spefic meaning. It is about a condition that the client stated in the request, whichthe server was unable to fullfill. Don't use this status code for your scenario.

The only HTTP status code that can be used is 400 Bad Request. It is the catch-all status code for all errors that the client can fix. Since you return detailed information about how the client can do this, the client has everything necessary.

see Wikipedia: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for confirming my suspicion that 412 was not right for this case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.