Dmitry
Dmitry

Reputation: 7563

HTTP response status code for lack of params in the request

I have an URI, that is available by POST.
It requires 4 POST params.

What HTTP response status code should I use if user doesn't pass me all the required params?

406?

Upvotes: 0

Views: 141

Answers (1)

Rafael Colucci
Rafael Colucci

Reputation: 6078

You better use 400 instead of 406:

406 Not Acceptable The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.[2

400 Bad Request The request cannot be fulfilled due to bad syntax.[2]

List of HTTP status codes

Also, you can generate an Exception that would be better since you can write a custom error that indicates what is wrong with the request.

Upvotes: 1

Related Questions