I'm calling an external POST API (no request body) that requires the request to be sent without a Content-Type header. In Node/axios this is done via Content-Type: null, and the API accepts it fine.
In OutSystems, I simply did not set/input a Content-Type value for this REST API method. Logging the Headers in OnBeforeRequest shows Content-Type is not in the list (or empty). But the server still returns HTTP 415 Unsupported Media Type (empty body), same as when Content-Type was explicitly set to application/json.
I suspect the OutSystems runtime might still be sending a default Content-Type header at the actual HTTP/wire level, after OnBeforeRequest, even though it's not shown in the Headers log.
Has anyone run into this? Is there a reliable way to confirm/control what Content-Type actually gets sent on the wire for a POST request?
I've done some tests as well, and they do not align perfectly with what others have posted.
POST https://emso.audaxenergy.nl/khtestrest2/rest/TestRest/HitMe HTTP/1.1 Connection: Keep-Alive Content-Length: 0 Host: emso.audaxenergy.nl User-Agent: OutSystemsPlatform OS-Host: emso.audaxenergy.nl OS-Path: /khtestrest2 OS-Pta: /rest/TestRest OS-Page: /HitMe
POST /khtestrest2/rest/TestRest/HitMe HTTP/1.1 Connection: Keep-Alive Content-Length: 11 Content-Type: text/plain; charset=UTF-8 Host: emso.audaxenergy.nl User-Agent: OutSystemsPlatform OS-Host: emso.audaxenergy.nl OS-Path: /khtestrest2 OS-Pta: /rest/TestRest OS-Page: /HitMe RhythmStick
POST https://emso.audaxenergy.nl/khtestrest2/rest/TestRest/HitMe HTTP/1.1 Connection: Keep-Alive Content-Length: 11 Content-Type: application/json Host: emso.audaxenergy.nl User-Agent: OutSystemsPlatform OS-Host: emso.audaxenergy.nl OS-Path: /khtestrest2 OS-Pta: /rest/TestRest OS-Page: /HitMe RhythmStick
POST /khtestrest2/rest/TestRest/HitMe HTTP/1.1 Content-Length: 11 Host: emso.audaxenergy.nl User-Agent: OutSystemsPlatform OS-Host: emso.audaxenergy.nl OS-Path: /khtestrest2 OS-Pta: /rest/TestRest OS-Page: /HitMe RhythmStick
So, concluding, I think most of what has been written in this thread (including mine!) is wrong. It is, on O11, perfectly possible to remove the Content-Type (by setting it to the empty string in the On Before Request of the REST consume), but it is also not needed as it isn't sent at all when there's no body. Removing it (when there is a body) causes an error, at least when it's an OS exposed REST method.
So, unless the error returned by the service is misleading and the error is caused by something else, could it be that content-length (and not content-type) is the culprit as it is always present?
I think Content-Length is mandatory when POSTing?
You are right, it is.
Hi @Nguyen Khac Bao ,
When I tested with https://webhook.site/ , even with a completely empty POST method, OutSystems is still creating an empty text content payload and sending:
What I did in order to remove the content-type is: in OnBeforeRequest I appended the Content-Type with an empty string.
And I got this result:
If that doesn't work you can try taking a look at this Advanced Customization / REST Extensibility API, it allows using your own .NET code to customize request/response data for consumed REST APIs
Hi @Mihai Melencu I tried your method, but it still doesn't seem to work. Error 415 is still being returned.
Are you able to create a sample OML with your API setup?
The endpoint does not need to be the real one, but I would need the request configuration to match your actual setup as closely as possible.
Hi,
This is the most common issue/cause. You need to explicitly tell the external server what format your data is in.
can you check what format/content type you send
thanks
CV
Hi @Chandra Vikas Sharma , thanks for the reply.
The request is a POST with an empty body. I've tried two cases:
Content-Type: application/json → 415
Not setting Content-Type at all (left empty) → still 415
In the working Node/axios implementation, Content-Type is explicitly set to null, which removes the header entirely from the outgoing request — and the server accepts it without error in that case.
So it seems the server specifically rejects requests that have any Content-Type header value (even empty string), and only accepts requests where the header is completely absent. I'm trying to confirm whether OutSystems can fully omit this header on the wire for a POST request.
Using the OnBeforeRequest (like Mihai mentioned) you can also add or remove headers from the list.
Request.Headers is a list, so all you have to do is to use ListIndexOf with the filter name="ContentType" and the returned index you can pass to the ListRemove.
After that, remember to set the output of the action (CustomizedRequest) to Request and it should work. If the problem is just the header being present.
Maybe the solution Mihai gave you didn't work because you forgot to assign Request to CustomizedRequest?
Here is the documentation with an example to ADD a header, instead of removing one.
Hope this helps.
Cheers
Though that generally works, Content-Type is a special case. In my article on how to expose a URL for downloading a file, I write:
To add the proper MIME type, we need to add another header, with the name “Content-Type”. Since Content-Type is a header that the Platform adds, and since it doesn’t recognize you already added a Content-Type header if you use the Output Parameter trick, to prevent two Content-Type headers in the returned message, we need to use the AddHeader action.
However, AddHeader is an action from the O11 HTTPRequestHandler extension, so I'm not sure how to do this in ODC.
I think they are on O11?
But it seems the problem is that the platform is adding the content type header, and the service is failing cause it is not expecting to receive it.
I added the example but the udea eould be to remove the header, instwad of adding a new one.
cheers!
Yes, the Platform adds a Content-Type header (on O11) if it's not explicitly added via the HTTPRequestHandler, and fails to detect an added header in the On Before Request. Adding an empty one should work (on O11), but again, no idea on ODC.
Oh, I linked the ODC docs. lol@Nguyen Khac BaoI've been reading and it's not possible to remove headers with the OnBeforeRequest in O11.
In order to remove headers, in your case, the Content-type, you will need to use an extension.Check here: https://success.outsystems.com/documentation/11/integration_with_external_systems/rest/consume_rest_apis/advanced_customizations/
Cheers!
This seems incorrect, see my experimentations below.
Hum... This is from documentation:
The presence of the Content-Type header is automatically set depending on how you configure the call (by your experiments). But this is an automation, it seems?
But you are right, as in this case (specifically?), would be possible to control the presence of the header, like Mihai did on the OnBeforeRequest.
So the error may not be related to this header specifically, or at least not only this one?
Hi @Nguyen Khac Bao First, enable Full Logs for the REST API in Service Center. Then invoke the API again and download the request/response details from the integration logs. Review the request payload and HTTP headers that OutSystems is sending. This will help you verify the exact request being sent and identify why the server is returning a 415 (Unsupported Media Type) response. Comparing the actual headers sent by OutSystems with the working request from Postman, Axios, or another client should help pinpoint the difference causing the issue.