api - What HTTP status code should I use for nickname validation? -
i building api , 1 of endpoints nickname validation company. read lot http status codes , entity validation 422
seems best choice. how 1 field validation in example?
what http status code should use nickname validation?
for example exists
i think 409 conflict appropriate pick
the 409 (conflict) status code indicates request not completed due conflict current state of target resource. code used in situations user might able resolve conflict , resubmit request. server should generate payload includes enough information user recognize source of conflict.
user 1 picked username, user 2 wants same, can't, because conflicts user 1's username
or has not allowed chars
for this, 422 unprocessable entity mentioned seems ok.
the 422 (unprocessable entity) status code means server understands content type of request entity (hence 415(unsupported media type) status code inappropriate), , the syntax of request entity correct (thus 400 (bad request) status code inappropriate) unable process contained instructions. example, this error condition may occur if request body contains well-formed (i.e., syntactically correct), semantically erroneous, instructions.
emphasis mine
Comments
Post a Comment