users@jersey.java.net

Re: Adding a resource - HTTP POST

From: Nam Nguyen <Nam.Nguyen_at_Sun.COM>
Date: Tue, 23 Oct 2007 12:15:24 -0700

Hi Florian,

You need to have the method return Response and use
Response.Builder.created(uri) as return value.

For sample codes, download NB 6.0 beta2
http://bits.nbextras.org/netbeans/6.0/beta2/latest/
and refer http://www.netbeans.org/kb/60/websvc/rest.html on how to
rapidly create database RESTful CRUD access.

-Nam

Florian Rosenberg wrote:
> Hi,
>
> I'm currently unit testing my resources. I have problems understanding the
> return code of a POST, for example, here is my method signature:
>
> @UriTemplate("customers/{id}")
> @HttpMethod("POST")
> public void addCustomer(@UriParam("id") String id, Customer data) {}
>
> Upon execution, the resource is created and returns a 204 code, which
> means "No content". This seems okay, but I rather expected a 201 "Created"
> response.
>
> Is this the default return code for a successful HTTP POST? I checked the
> JavaDoc API, but I could not find any annotation that would allow me to
> set the return code I want to have.
>
> Thanks,
> -Florian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>