I am thinking 412 (Precondition Failed) but there may be a better standard?
views:
73answers:
3You can send a 400 Bad Request code. It's one of the more general-purpose 4xx status codes, so you can use it to mean what you intend: the client is sending a request that's missing information/parameters that your application requires in order to process it correctly.
I'm not sure there's a set standard, but I would have used 400 Bad Request
:
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
The WCF API in .NET handles missing parameters by returning an HTTP 404
"Endpoint Not Found" error, when using the webHttpBinding.
The 404 Not Found
can make sense if you consider your web service method name together with its parameter signature. That is, if you expose a web service method LoginUser(string, string)
and you request LoginUser(string)
, the latter is not found.
Basically this would mean that the web service method you are calling, together with the parameter signature you specified, cannot be found.
The 400 Bad Request
, as Gert suggested, remains a valid response code, but I think it is normally used to indicate lower-level problems. It could easily be interpreted as a malformed HTTP request, maybe missing or invalid HTTP headers, or similar.