users@jersey.java.net

[Jersey] Re: Sending a PATCH request from JAX-RS client?

From: Markus Karg <karg_at_quipsy.de>
Date: Tue, 7 Apr 2015 22:10:17 +0200

See https://blogs.oracle.com/PavelBucek/entry/jersey_client_making_requests_with but AFAIK the name of the property was changed meanwhile.

Regards
-Markus


From: dancingcloudphotography_at_gmail.com [mailto:dancingcloudphotography_at_gmail.com] On Behalf Of Simon Roberts
Sent: Dienstag, 7. April 2015 21:55
To: users_at_jersey.java.net
Subject: [Jersey] Sending a PATCH request from JAX-RS client?

I have been bullied into using the PATCH approach for partial updates, and had no problem creating a server side annotation and implementation for this.

However, when I try to write client code for testing, it fails. It seems to be systemic, rather than an error on my part, as the error shows up as

java.net.ProtocolException: Invalid HTTP method: PATCH
            at java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:440)

and a quick check of the documentation for HttpURLConnection does indeed indicate that it's unwilling to allow anything other than the specfic methods it lists, and that list doesn't include PATCH.

So is the JAX-RS client unable to do PATCH (or other custom methods)? Or is there some approach to getting this to work?

In case it's of any interest, my attempt to create this request is nutshelled in this:

Response r = ib1.build("PATCH", Entity.json(new CustomerTO("Phoenix", null))).invoke();

Any pointers will be gratefully accepted...

Cheers,
Simon


--
Simon Roberts
Certified Professional Photographer
http://dancingcloudphotography.com
(303) 249 3613