I have a RESTful API who's document says that a certain query parameter is optional, and does not supply a default argument. So, I can either supply the value or not send it in the GET request as a parameter.
Example:
queryA
is requiredqueryB
is optional (can sendGET
without it)
This should work:
http://www.example.com/service/endpoint?queryA=foo&queryB=bar
This should also work:
http://www.example.com/service/endpoint?queryA=foo
How do I make an client interface for Jersey-Proxy that can do this?? I do not have the server-side code to interface with so I am using org.glassfish.jersey.client.proxy.WebResourceFactory
via Jersey-Proxy to generate the client to interact with the server API.
Sample interface:
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
@Path("/service")
@Produces("application/json")
public interface ServiceInterface {
@Path("/endpoint")
@GET
public Response getEndpoint(
@QueryParam("queryA") String first,
@QueryParam("queryB") String second);
}
I know I can make another method:
@Path("/endpoint")
@GET
public Response getEndpoint(
@QueryParam("queryA") String first);
But what happens when you have multiple optional fields?? I don't want to make every possible mutation of them!