users@jersey.java.net

[Jersey] Re: Problem Differentiating REST APIs with different @QueryParams

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Fri, 19 Apr 2013 09:51:58 -0700

I don't think this is possible. Dispatching is based on path, and query
parameters are not considered as part of path for purposes of dispatching
-- there is the question of existence of a query parameter (is empty String
missing or not?), and performance considerations.

So you need to map specific path (or path template), verb, into just one
method.

-+ Tatu +-


On Fri, Apr 19, 2013 at 5:24 AM, Tope Faro <topriddy_at_gmail.com> wrote:

> Hi all,
>
> I am currently having problems using Jersey API as I cannot map the
> theoretic REST in principle to it's implementation with Jersey Library.
>
> At the moment, I am facing an error below:
>
> *SEVERE: Producing media type conflict. The resource methods public
> java.util.List
> com.topriddy.rest.CustomServiceResource.getAllInventoryItemsByInventoryCategoryId(java.lang.Long)
> and public java.util.List
> com.topriddy.rest.CustomServiceResource.getAllInventoryItemsByInventoryCategoryIdAndDeleted(java.lang.Long,java.lang.Boolean)
> can produce the same media type*
> *
> *
> The above seems to be caused by the fact that I am trying to create an api
> where i can get list of inventories based by different query parameters.
>
> The issue is i would wish to be able to differentiate method calls by
> @QueryParams just as demonstrated in the Teach a Dog Rest examples.
>
> /dogs?color=red&state=running&location=park
>
>