How to invoke custom HTTP methods from Wink client

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to invoke custom HTTP methods from Wink client

Hasini Gunasinghe
Hi all,

I need to invoke a custom HTTP method (PATCH) defined in JAX-RS based REST resource.
Can you please let me know how to send request to this custom HTTP method from wink client side?

I used 'invoke' method in org.apache.wink.client.Resource which allows to pass the http method as a parameter, but it gave the error: java.net.ProtocolException: Invalid HTTP method: PATCH

Appreciate any insight on how to achieve the above requirement.

Thanks,
Hasini.
Reply | Threaded
Open this post in threaded view
|

Re: How to invoke custom HTTP methods from Wink client

tgras
This post has NOT been accepted by the mailing list yet.
I had to do the same thing (use the PATCH http method) and thought I would share how I did it for anyone else.

ClientResponse response;
try {
    response = resource.contentType(contentMimeType).accept(acceptMimeType).invoke("PATCH", ClientResponse.class, content);
} catch (ClientWebException e) {
    response = e.getResponse();
}

I came to this by looking at the invokeNoException method of the org.apache.wink.client.internal.ResourceImpl Class.  It seems to work well.