How is your experience with the OutSystems Community?
25
Views
17
Comments
Solved
 415 error when calling external POST API

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?

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

I've done some tests as well, and they do not align perfectly with what others have posted.

  • POST method, no parameters. There is no content, so there's no content type. Integration Logging shows the same content as the HTTPRequestHandler extension's GetRequestContent with IncludeHeaders = True in the exposed API's On Request:

    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 method, single body parameter of type Text, caller has RequestFormat set to Text/plain. Now there's a body, so there's a Content-Type with "text/plain; charset=UTF-8":

    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
  • In the OnBeforeRequest, loop over the CustomizedRequest.Headers list, and if it's Content-Type, change it to application/json. This seems to work! In previous experiments (with Multipart/form-data) this didn't work (or at least that's what I've written down):

    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
  • Now set the Content-Type to the empty string, instead of a value. Inside the On Request of the exposed REST API, we can see that now the Content-Type is removed! This results in an error in Service Center, "The format of value '' is invalid." This makes sense, as we do send a body, but there's no Content-Type:

    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.

2026-06-05 12-38-17
Eduardo Jauch

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? 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

I think Content-Length is mandatory when POSTing?

2026-01-28 16-57-48
Mihai Melencu
Champion

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 

UserImage.jpg
Nguyen Khac Bao

Hi @Mihai Melencu 
I tried your method, but it still doesn't seem to work. Error 415 is still being returned.

2026-01-28 16-57-48
Mihai Melencu
Champion

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.

2024-03-22 09-17-23
Chandra Vikas Sharma

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

UserImage.jpg
Nguyen Khac Bao

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.

2026-06-05 12-38-17
Eduardo Jauch

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

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

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.

2026-06-05 12-38-17
Eduardo Jauch

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!

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

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.

2026-06-05 12-38-17
Eduardo Jauch

Oh, I linked the ODC docs. lol

@Nguyen Khac Bao
I'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!

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

This seems incorrect, see my experimentations below.

2026-06-05 12-38-17
Eduardo Jauch

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?


2025-08-07 06-30-56
Amit J
Champion

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.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

I've done some tests as well, and they do not align perfectly with what others have posted.

  • POST method, no parameters. There is no content, so there's no content type. Integration Logging shows the same content as the HTTPRequestHandler extension's GetRequestContent with IncludeHeaders = True in the exposed API's On Request:

    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 method, single body parameter of type Text, caller has RequestFormat set to Text/plain. Now there's a body, so there's a Content-Type with "text/plain; charset=UTF-8":

    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
  • In the OnBeforeRequest, loop over the CustomizedRequest.Headers list, and if it's Content-Type, change it to application/json. This seems to work! In previous experiments (with Multipart/form-data) this didn't work (or at least that's what I've written down):

    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
  • Now set the Content-Type to the empty string, instead of a value. Inside the On Request of the exposed REST API, we can see that now the Content-Type is removed! This results in an error in Service Center, "The format of value '' is invalid." This makes sense, as we do send a body, but there's no Content-Type:

    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.

2026-06-05 12-38-17
Eduardo Jauch

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? 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

I think Content-Length is mandatory when POSTing?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.