> 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.
Right. What you want is one method that responds to the /dogs path and
takes all of the possible query parameters, e.g.:
@GET()
@Produces(MediaType.APPLICATION_JSON)
public List<Dog> dogsByQuery(
@QueryParam("color") @DefaultValue("none")
String color,
@QueryParam("state") @DefaultValue("none")
String state,
@QueryParam("location") @DefaultValue("none")
String location) {
// code that does query here
}
You can use the @DefaultValue() annotation to make it easier to handle when
a query parameter isn't set. Otherwise those values will be null.
;ted
On Fri, Apr 19, 2013 at 9:51 AM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:
> 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
>>
>>
>