users@jersey.java.net

Re: Adding a resource - HTTP POST

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 23 Oct 2007 17:27:46 -0400

On Oct 23, 2007, at 3:15 PM, Nam Nguyen wrote:
>
> You need to have the method return Response and use
> Response.Builder.created(uri) as return value.
>
Right. A 204 status is the default for a method that returns void, to
get another status you need to return an instance of Response and
Response.Builder provides an easy way to create one.

Marc.

> 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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.