Hello everybody,
I'm developing a rest web service on GAE. I'm using Jersey framework
to implement the REST services. It is a POST service where I have to
pass also parameters. I tried to use 2 types of annotation but I can't
get the parameters:
with the annotation @Context
@POST
@Path("add")
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Notification addUser(@Context UriInfo uriInfo){
MultivaluedMap<String, String> queryParams =
uriInfo.getQueryParameters();
String nickname = queryParams.getFirst("nickname");
String name = queryParams.getFirst("name");
String surname = queryParams.getFirst("surname");
String telephone = queryParams.getFirst("telephone");
String email = queryParams.getFirst("email");
User =createUser(nickname, name, surname, telephone, email);
.......
}
with the annotation @QueryParam
@POST
@Path("add")
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Notification addUser(@QueryParam("nickname") String nickname,
@QueryParam("name") String name, @QueryParam("surname") String
surname, @QueryParam("telephone") String telephone,
@QueryParam("email") String email) {
User =createUser(nickname, name, surname, telephone, email);
......
}
But in both cases I can not get the parameters all of them are null
values.
This is an example of my http request:
Request URL: http://windyser.appspot.com/rest/users/add
Request Method: POST
Params:
{"nickname":"prova","name":"danilo","surname":"delizia","email":"[email protected]","telephone":"123"}
Sent Headers
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept-Language: en
I also tied the @Consumes("text/plain") and @Consumes("application/x-
www-form-urlencoded") annotations, but it still does not work. In the
first case I get an "Unsupported Media Type" from GAE. And the second
case i get null parameters.
Anybody know if I'm doing something wrong?
Thanks in advance for your help
Danilo
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.