Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid HTTP method: PATCH > executing PATCH : Caused by: feign.RetryableException:

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)

like image 473
user2775185 Avatar asked Feb 12 '16 23:02

user2775185


3 Answers

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>
like image 74
D-rk Avatar answered Nov 14 '22 02:11

D-rk


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

like image 14
Adam Karpowich Avatar answered Nov 14 '22 02:11

Adam Karpowich


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
like image 3
Soumyajit Swain Avatar answered Nov 14 '22 02:11

Soumyajit Swain