Override value of HTTP header Content-Length


When I consume an external API with OutSystems then the application by default adds an Content-Length header, as can be seen in the Integrations (Monitoring) tab of servicecenter. Basically it is the number of bytes of data in the body of the request. In this case the body is of Content-Type application/x-www-form-urlencoded.

When I try the API call in Postman then the Content-Length is 71 and I get a valid response with HTTP status 200, but when I try exactly the same call in OutSystems the Content-Length is 69 and I get an HTTP status 400 (Bad request).

So I manually altered the value of the Content-Length header in Postman to 69 and this results in an HTTP status 400 (Bad request).

I suspect that Postman includes the beginning- and end- quote in the calculation of the Content-Length (as does the API provider) and OutSystems doesn't include those quotes.

Does someone know how I can fix this? Is there a way to override the value of HTTP header Content-Length? I have tried setting it in the OnBeforeRequest, but the platform still seems to overrule this and add the by the platform calculated value.

Best regards,


Hi Funs,

I haven't tried this, but you should be able to manipulate this header on the "OnBeforeRequest" of your consumed API.



Hi Rui,

Thanks for your reply. I have tried that as one of the possible solutions. But the OutSystems platform seems to overrule the value of the Content-Length header.

We did some more detailed analysis of the issue and we found the problem. The Problem occurred because the password of the API contained a "+" character. Postman encodes this to an URL and changes the "+" to "%2B", but OutSystems doesn't although the Request Format property of the REST API Method is set to "Form URL Encoded". One would assume that the body of the request will URL encoded, but the integration logging shows it is not. Therefor the Content-Length header does not have the correct value which results in a HTTP status 400 (Bad request).

We fixed it in our module by using the URLEncode action of the HTTPRequestHandler extension. Note that the Built-in Function 'EncodeUrl' did not work.

OutSystems has notified us that they will make a patch for this issue.

Best regards,