Errabi Ayoub Errabi Ayoub - 1 year ago 126
reST (reStructuredText) Question

Is @Consumes annotation required or optional in the DELETE method Jersey

I'm new in jersey rest service and I want to understand in this example the utility of adding

annotation to a delete method in this case this is the code it's work well (in a video ), is the
annotation optional here ? Thanks in advance

public class ActivityResource {

public Response delete(@PathParam("activityId")String activityId) {
return Response.ok().build() ;

Answer Source

A DELETE should not be interested in anything that is in the request body. It should only identify the resource to be deleted based on the URI.

Remove the @Consumes, it is wrong here.

Also think about returning a HTTP status 204 No Content instead of 200 OK. After deleting a resource, there is nothing to return. You should also remove the @Produces because of this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download