views:

73

answers:

3

I am thinking 412 (Precondition Failed) but there may be a better standard?

+1  A: 

You 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.

BoltClock
+9  A: 

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.

Gert G
`400 Bad Request` is meant to indicate protocol-level problems, not semantic errors.If we're going to hijack HTTP status codes to indicate application-level (rather than protocol-level) errors, why not go all the way and just use `412`?
Matt Zukowski
A: 

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.

Daniel Vassallo