users@jersey.java.net

[Jersey] Re: POST with no argument

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

That's the difference. If you put the query paran in the path string per my example you should see it fail. Is that not considered legal?

Sent from my iPhone

> On Dec 13, 2013, at 8:46 PM, "Bill O'Neil" <oneil5045_at_gmail.com> wrote:
>
> ClientBuilder.newClient().target("http://localhost:8080/footest").queryParam("foo", "notnull").request().post(null);
>
>
>
> works fine
>
>
>
>> On Fri, Dec 13, 2013 at 11:44 PM, Robert DiFalco <robert.difalco_at_gmail.com> wrote:
>> 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?
>