tags:

views:

41

answers:

2

I am currently using Jersey Framework (JAX-RS implementation) for building RESTful Web Services. The Resource classes in the project have implemented the standard HTTP operations - GET,POST & DELETE. I am trying to figure out how to send request parameters from client to these methods.

For GET it would be in the query string(extract using @QueryParam) and POST would be name/value pair list (extract using @FormParam) sent in with the request body. I tested them using HTTPClient and worked fine. For DELETE operation, I am not finding any conclusive answers on the parameter type/format. Does DELETE operation receive parameters in the query string(extract using @QueryParam) or in the body(extract using @FormParam)?

In most DELETE examples on the web, I observe the use of @PathParam annotation for parameter extraction(this would be from the query string again).

Is this the correct way of passing parameters to the DELETE method? I just want to be careful here so that I am not violating any REST principles.

A: 

@QueryParam would be the correct way. @PathParam is only for things before any url parameters (stuff after the '?'). And @FormParam is only for submitted web forms that have the form content type.

Gandalf
+2  A: 

The DELETE method should use the URL to identify the resource to delete. This means you can use either path parameters or query parameters. Beyond that, there is no right and wrong way to construct an URL as far as REST is concerned.

Darrel Miller