Feign: Invalid HTTP method: PATCH

Created on 12 Feb 2020  路  7Comments  路  Source: OpenFeign/feign

Invalid HTTP method: PATCH executing PATCH https://......

@RequestLine("PATCH /v1/api/customers?customerId=1)

How can I solve this?

needs info

Most helpful comment

I have come across this issue recently.
The Default client (Default implements Client) is using HttpsURLConnection in which the valid HTTP methods are
private static final String[] methods = { "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE" };
PATCH is not in the list, results the exception. Feign had nothing to with the issue.

I am using ApacheHttpClient for PATCH Requests now.

All 7 comments

This issue does not have enough information. Please update this issue with the following:

  • A brief description of what you are trying to do.
  • Expected vs Actual outcome
  • A minimum working example demonstrating the issue.

Basically i'm calling a partner api, that requires to do a PATCH to https://domain.com/v1/user/1.

in my code i basically have something like this, for example:
@RequestLine("PATCH v1/user/1?customerId=1)

Im expecting a Response object, because the api only return the status code without body.

When I call the method that do this request, i got that error exception:
Invalid HTTP method: PATCH executing PATCH https://......

When i debug in your Client.java, i see that PATCH http method is not in the list of the methods allowed by HTTPUrlConnection.

I'm using the v 8... But i already tried the most recent one, and the problem persists. I tried to do a simple HTTPUrlConnection without feign (https://stackoverflow.com/posts/46323891/revisions) and it worked. However i would like to have this working with feign.

Can you attach the stack trace? Preferably on a more recent version of feign, as I'm very unlikely to troubleshoot feign 8.

The only thing i got in the stack trace is this:
Invalid HTTP method: PATCH executing PATCH https://......

I wasn't able to active the logs in debug level :(

Plan B, submit a unit test that demonstrates the problem. To the best of my knowledge PATCH just works

In my routes file:
@RequestLine("PATCH /v1/applications/stuff/customers?country=PT&id={id}") public Response getMyMethod(@HeaderMap Map<String, Object> headerMap, @Param("id") String id);

Then i call this method, in the map i just pass the API key.

and I just get that message. No more information i can give to you

I have come across this issue recently.
The Default client (Default implements Client) is using HttpsURLConnection in which the valid HTTP methods are
private static final String[] methods = { "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE" };
PATCH is not in the list, results the exception. Feign had nothing to with the issue.

I am using ApacheHttpClient for PATCH Requests now.

Was this page helpful?
0 / 5 - 0 ratings