Hi Nicolas,
> This might be a silly question, but is there a way to configure how the JAX 
> RS extention will react to illegal values for @QueryParameter annotated 
> parameters?
>
> Say for example that you have a @QueryParameter("count") int count field and 
> that a client sets the value of the parameter to "zorglub". This is obviously 
> not a legal integer and the JAX RS specifications tell us that this should be 
> dealt with by returning a 404 error code.
>
> This makes sense when query parameters are "part of the path". There are lots 
> of cases however where this error code is just not correct. Imagine for 
> example that your REST application serves reports. You'd typically have 
> /reports to serve all available reports and /reports/{id} to serve an 
> individual report.
> In this case, it's fairly common to accept query parameters in /reports as 
> filters to the list of reports (number of items, author name, creation date 
> min....). Returning a 404 when one of these parameters is just not correct 
> and we should return 400 (the resource was found, but the request was "bad").
>   
Do you mean you want to request something like "/reports?lastname=smith" 
or "/reports/4?lastname=smith"?

"/reports" and "/reports/68", "/reports?lastname=smith" and 
"/reports/68?lastname=smith" are 4 different resources. So error doe 404 
is right. But perhaps I misunderstood your scenario.
> Is there any way to override the default error code, or do we have to 
> retrieve each parameter as a string and do the analysis ourselves? It seems 
> to somewhat defeat the purpose of the mechanism...
No, it is not possible now. Formally the HTTP specification allows no 
freedom of interpretation.

best regards
    Stephan

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2380720

Reply via email to