we are using netflix feign to make call to restful web service. For patch request it looks like PATCH request is not supported.
Caused by: feign.RetryableException: Invalid HTTP method: PATCH executing PATCH https://projects.dev.xyz.com/projects/v1/users/{uid}/projects/{guid} at feign.FeignException.errorExecuting(FeignException.java:66) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:100) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:74) at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:54) at com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:294)
if someone encounters the same problem with spring-cloud-feign, using the httpClient from feign can be achieved by just adding the maven dependency:
<dependency>
<!-- Required to use PATCH -->
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>${feign.version}</version>
</dependency>
You can solve this by using the httpClient from feign. You want to first add the module to your classpath, then configure it when you're building your object with
Feign.builder().client(new ApacheHttpClient())
. This adds support for PATCH requests.
Link to Doc: https://github.com/Netflix/feign/tree/master/httpclient
EDIT: there is also a feign object that wraps apache's http client, link here
I also faced the same issue but managed to solve it by adding the feign-httpclient dependency and adding a additional header X-HTTP-Method-Override : PATCH in the request.
<dependency>
<!-- Required to use PATCH -->
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>${feign.version}</version>
</dependency>
Add a header
@RequestHeader(value="X-HTTP-Method-Override", defaultValue="PATCH") String xHttpMethodOveride
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With