Reputation: 4278
I'm working on REST web-service where in one PUT request i have to accept two things :
String id;
JSON
representation of POJO
(Basically a POJO).
I can have a @PathParam for 'id' but what should i use for 'second' parameter (POJO)?.
How can i write my method for PUT request:
@PUT
public String doSomething(// What will go here?)
{
// code
}
Upvotes: 1
Views: 1033
Reputation:
@PUT
@Path("/{id}")
@Accepts("application/json")
public Response putPojo(@PathParam("id") String id, Pojo pojo) {
return Response.ok().build();
}
If the Pojo
class has JAXB annotations, JAX-RS will map the incoming JSON to a POJO
instance.
@XmlRootElement
public class Pojo {
@XmlElement
String id;
// Getter, Setter, ...
}
Upvotes: 2