1
votes

I have setup a REST endpoint in WSO2 AM that calls out to another REST endpoint. When the call is made I am receiving a 411 response code. The request contains a JSON body, the content type and accepts header are set to application/json. I can curl the backing service that WSO2 is accessing directly with the same params and it works correctly. It seems that WSO2 AM is stripping or not sending the content-length.

Why is the content length not being sent to the REST endpoint that is being accessed?

1
On what API Manager version are you trying? are you sending a put or post request?lakshman
POST and version 1.10Mike H

1 Answers

0
votes

Sending content-length is disabled by default because it can cause performance degradation. But you can enable it by adding following to the api's insequence. (see https://docs.wso2.com/display/AM1100/Adding+Mediation+Extensions on adding custom sequence to an api)

<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"/>
<property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"></property>

following is a sample sequnce

<sequence xmlns="http://ws.apache.org/ns/synapse" name="contentLengthadd">
    <property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"/>
    <property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"></property>
</sequence>

This sequence will get the content length from incoming request request and pass it the request header to the backend.

you can read more about these two properties in https://docs.wso2.com/display/ESB481/HTTP+Transport+Properties#HTTPTransportProperties-FORCE_HTTP_CONTENT_LENGTH