So I’m developing a Rest API
When a POST is made to create a resource and a required field is missing what should I return?
400 – Bad Request
OR
412 – Precondition Failed
And Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use 400 if the request parameters are wrong. Use 412 if one of the
If-*request headers likeIf-Match,If-Modified-Since, etc are wrong.Why? That’s just what RFC says. See for example this extract of
If-Matchspecification: