kaka
kaka

Reputation: 7915

Resltlet mapping resources with URLs containing queryparam

I have to develop a rest web service. For this i am using restlet api.
I have 3 get urls:

 1. /info/person?name=aaa
 2. /info/person?name=aaa&age=21
 3. /info/person?name=aaa&age=21&sex=male

I want to map these urls to 3 different resources methods.

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.QueryParam;

@Path("/info/person")
@Produces(MediaType.APPLICATION_XML)
public class TestResource{

//method 1
@GET
public Response getInfo(@QueryParam("name") final String name){
...
}

//method 2
@GET
public Response getInfo(@QueryParam("name") final String name){
....
}

//method 3
@GET
public Response getInfo(@QueryParam("name") final String name, @Queryparam("age") final int age, @Queryparam("sex") final String sex){
....
}
}

I expect that for url1, method 1 will be invoked, for url2, method 2 will be invoked and for url3, method 3 will be invoked.

But this doesn't works. The expected methods are not called.

Please help me in identifying where i am doing the mistake.

restlet version : 2.3.4

Upvotes: 0

Views: 55

Answers (1)

Rolson Quadras
Rolson Quadras

Reputation: 446

JAX-RS doesn't allow to have two endpoints with same HTTP Path and different query params.

Suggest you to go through - Two GET methods with different query parameters : REST

Upvotes: 1

Related Questions