Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read post data in a Jersey based RESTful webservice

How do i read the data which i pass in a POST or PUT method using -d option in curl

curl -XPUT host:port/service -d 'some data'

Is there an annotation similat to like @QueryParam for query parameters?

like image 595
FUD Avatar asked Dec 25 '11 17:12

FUD


People also ask

What is Jersey in RESTful web services?

Jersey is Sun's production quality reference implementation for JSR 311: JAX-RS: The Java API for RESTful Web Services. Jersey implements support for the annotations defined in JSR-311, making it easy for developers to build RESTful web services with Java and the Java JVM.

What is the difference between JAX-RS and Jersey?

JAX-RS is an specification (just a definition) and Jersey is a JAX-RS implementation. Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides its own API that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development.


1 Answers

This works for me. There is no need for any annotations.

WebService

@POST
@Path("/foo")
public void foo(String data) {
    System.out.println(data);
}

Output

some data

Similar:

How do I read POST parameters for a RESTful service using Jersey?

like image 191
user219882 Avatar answered Sep 26 '22 15:09

user219882