Feign client is not working with @Patchmapping or PATCH method

18 Views Asked by At

Caused by: java.net.ProtocolException: Invalid HTTP method: PATCH at java.base/java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:489) at java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:598) at feign.Client$Default.convertAndSend(Client.java:171) at feign.Client$Default.execute(Client.java:105) at org.springframework.cloud.openfeign.loadbalancer.LoadBalancerUtils.executeWithLoadBalancerLifecycleProcessing(LoadBalancerUtils.java:56) at org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient.lambda$execute$2(RetryableFeignBlockingLoadBalancerClient.java:189) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:329) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:225) at org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient.execute(RetryableFeignBlockingLoadBalancerClient.java:136) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:100) ... 183 more

1

There are 1 best solutions below

0
Santhoshkannan On

Just found the answer which worked for me yesterday...

add the below dependency to pom or any build config

    <dependency>
        <groupId>io.github.openfeign</groupId>
        <artifactId>feign-okhttp</artifactId>
    </dependency>

and add the below bean method for initialisation of okhttp

@FeignClient(name = "<1feign name>", configuration = { FeignConfiguration.class }) public interface ProductService {

"FeignConfiguration" should be added in this configuration class @Bean public OkHttpClient client() { return new OkHttpClient(); }