I am trying to access one existing REST service from my client side using JAX-RS client as below-
public interface ServerApi {
@POST
@Path("/server/{type}/add")
void addServer(@PathParam("type") String type);
}
Here I want to pass a map as method parameter and JAX-RS client will convert that to query parameters.
For example, if I pass a map ([name=test, vendor=top1]
) as parameter (i,e, serverApi.addServer("linux", map);
), JAX-RS client will transform it to /server/linux/add?name=test&vendor=top1
I tried to write the client interface method as below -
public interface ServerApi {
@POST
@Path("/server/{type}/add")
void addServer(@PathParam("type") String type, @PathParam("map") Map<String, String> aMap);
}
But it will not work as client will assign the entire map to map key and pass that query parameter and I am not expecting that.
Can anyone help me to achieve this using JAX-RS client