users@jersey.java.net

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

From: Simon Roberts <simon_at_dancingcloudphotography.com>
Date: Tue, 7 Apr 2015 13:54:53 -0600

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