Skip to main content

I have a http connector in a process flow which communicates with a .net core 3.0 web api. The API can both produce XML and JSON:

>HttpPost]
>Produces("application/xml", new stringg] { "application/json" })]
public IActionResult Post()

If I do a call with no accept headers specified, this API returns the content as application/json. According to the documentation you can add headers to the HTTP connector:

> { "Key": "Accept", "Value": "application/json" } ]

or:

> { "Key": "Accept", "Value": "application/xml" } ]

To specify the expected result content type, so if XML is required, the last header should be applied.

When I add this and execute the http connector it shows me the following message:

The 'Accept' header must be modified using the appropriate property or method.
Parameter name: name

With a stack trace:

The 'Accept' header must be modified using the appropriate property or method.
Parameter name: name

   at System.Net.WebHeaderCollection.ThrowOnRestrictedHeader(String headerName)
   at System.Net.WebHeaderCollection.Add(String name, String value)
   at Thinkwise.Shared.ObjectModel.ProcessAction.NoContext.HttpConnector.PerformInternal(ActiveProcessFlow activeFlow, Pending pendingProcessAction, TSFController targetController)
   at Thinkwise.Shared.ObjectModel.ProcessAction.Perform(ActiveProcessFlow activeFlow, Pending pendingProcessAction, TSFController sourceController)
   at Thinkwise.Shared.ActiveProcessFlow.executeActiveProcessAction(IProcessActionStartParameters startParameters)

 

I have no clue what I'm doing wrong, and it looks very familiar to these topics:

https://community.thinkwisesoftware.com/development-13/http-connector-output-issue-i-think-290 (last post)

and

https://community.thinkwisesoftware.com/development-13/http-connector-results-into-411-length-required-726

How can i make sure the accepted content type is as specified?

Hello René,

 

It looks like some headers have to be added to the request in another way, e.g. Accept, Content-Type, Content-Lenght and maybe more. 

 

I created a User Story which we will get into in the upcoming sprint. When an update is available we will let you know.

 

Kind Regards,

Roel


Hello René,

The accept header will now no longer be added to the normal headers, for it has a separate property to set the value for this. This also counts for Content-Length and Content-Type headers.

If you are interested you can see a list of all special headers here:
https://docs.microsoft.com/en-us/dotnet/api/system.net.webheadercollection.isrestricted?view=netframework-4.8

We now use that method to check if the given header can be set in a normal way or should be set with a separate property.

The next GUI release which will come the 3rd of March will contain this fix.

If you have any further questions please let me know.

Kind Regards,

Roel


Reply