Feign: Getting 411 Length Required Error

Created on 17 Jul 2020  路  9Comments  路  Source: OpenFeign/feign

I am trying to have a post call with token and hitting to the end URL, I am receiving 411 Length Required error. Even after creating the Interceptor and adding Content-Length: 0 to it, still I am receiving the same error. I am able to see that request has content-length : 0 but I am not able to understand how to resolve this issue. I am using here default feign client

feedback provided question

All 9 comments

@mayank-jain02 To isolate where the issue may be, can you try using one of the other http clients, such as our OkHttp or Apache versions?

@kdavisk6 I have tried using Apache HttpClient and it is working using that.

I've excactly the same problem with the azure TTS-API.
This is being sent to azure:
image

this is the log:

2020-11-02 09:48:07.652 DEBUG 14696 [        Timer-0] f.s.Slf4jLogger                          : [AzureTokenHttpClient#postIssueTokenRequest] ---> POST https://westeurope.api.cognitive.microsoft.com/sts/v1.0/issueToken HTTP/1.1
2020-11-02 09:48:07.653 DEBUG 14696 [        Timer-0] f.s.Slf4jLogger                          : [AzureTokenHttpClient#postIssueTokenRequest] Content-Length: 0
2020-11-02 09:48:07.653 DEBUG 14696 [        Timer-0] f.s.Slf4jLogger                          : [AzureTokenHttpClient#postIssueTokenRequest] Content-Type: application/x-www-form-urlencoded
2020-11-02 09:48:07.653 DEBUG 14696 [        Timer-0] f.s.Slf4jLogger                          : [AzureTokenHttpClient#postIssueTokenRequest] Ocp-Apim-Subscription-Key: key
2020-11-02 09:48:07.653 DEBUG 14696 [        Timer-0] f.s.Slf4jLogger                          : [AzureTokenHttpClient#postIssueTokenRequest] ---> END HTTP (0-byte body)

and this is what I've got when I just changed the url pointing to a local test server:
image

Notice that also a User-Agent header is set without showing it in the debug console or log.

I've tried to explicitly enable
feign.okhttp.enabled: true
and with the same result
feign.httpclient.enabled: true

@kdavisk6 just pinging you as I don't know if you subscribed to this issue 馃樃

Hey @Somebodyisnobody, I'm facing the same issue with a pretty simple POST (without any body). Do you have any advice how to workaround the issue? I have tested my code with 10.10.1, 10.11 and 11.0.

Thanks

No I've no workarround for this and hope that someone who knows the code can help us

See also #1229

I was able to workaround the issue providing an empty JSON object ("{}") in the payload, worked like a charm. HTH

Thank you, that worked for me but I had to remove the Content-Type header and the manually set Content-Length header.

This does not fix the initial problem that values are shown in debugging which are not actually sent and that the Content-Length isn't zero.

Was this page helpful?
0 / 5 - 0 ratings