TechArtificer
TechArtificer

Reputation: 97

What status error to return when request fails a server logic (if-else condition)

I have a server-side logic that will rollback the SQL transaction if the object fails an if-else condition.

Server logic: My API route will send an evaluation report to a job client, but will check first through an if-else condition if the job first is completed (through a select query).

My question is: What error code will I return to the user? I'm currently using Error 401, but not sure if it's correct or appropriate.

Thank you!

Upvotes: 0

Views: 58

Answers (1)

Evert
Evert

Reputation: 99851

If you are fetching a report, but the report doesn't exist (yet) because the process that generates the report is not yet completed, that sounds like a 404 Not Found to me.

Alternatively, if something else needs to be done by a client before the report is available, 409 Conflict might also be a good fit.

401 is definitely not.

Upvotes: 2

Related Questions