users@jersey.java.net

[Jersey] Re: POST with no argument

From: Robert DiFalco <robert.difalco_at_gmail.com>
Date: Fri, 13 Dec 2013 20:44:39 -0800

Right because I think the issue is the client API.

Sent from my iPhone

> On Dec 13, 2013, at 8:33 PM, "Bill O'Neil" <oneil5045_at_gmail.com> wrote:
>
> I have no issues with this.
>
> Jersey 2.4.1
>
> @Path( "/footest" )
> @POST
> public void iDoNotKnowHowToDebug(
> @QueryParam( "foo") String foo,
> @Context UriInfo uriInfo ) throws Exception {
> System.out.println( "foo=" + foo );
> }
>
> curl -X POST "localhost:8080/footest?foo=notnull"
>
> output: foo=notnull
>
>
>> On Fri, Dec 13, 2013 at 11:18 PM, Robert DiFalco <robert.difalco_at_gmail.com> wrote:
>> I'm back with more questions found while upgrading from 1.9 to 2.4.1. I don't know if this is a client or a server issue.
>>
>> But if I perform a POST with no PathParam but with a QueryParam then the QueryParam will be overwritten with null. For example:
>>
>> @Path( "/footest" )
>> @POST
>> public void badlyDesignedPostOperation(
>> @QueryParam( "foo") String foo,
>> @Context UriInfo uriInfo ) throws Exception {
>> System.out.println( "foo=" + foo );
>> }
>>
>>
>> Now the test code:
>>
>> resource().path( "/footest?foo=notnull" ).method( "POST" );
>>
>> Instead of "notnull" the output will be null because null with overwrite the QueryParameter. I'm guess POST was implemented to always think a parameter was being sent so it ends up overwriting the query parameter as a path parameter.
>>
>> Is this expected?
>