question

Shuo C2 avatar image
1 Like"
Shuo C2 asked Phil BoBo commented

Change Http.Request Content Type header

I'm, trying to send a POST request with JSON data using the Http.Request API. I'm able to hit my own server from Flexsim, but I get back a 502. On the server end, its failing to read the request because it default content type send by the Flexsim Http Request is

'content-type': 'application/x-www-form-urlencoded'

Is there a way to change this header to 'application/json'? The docs don't seem to list anything obvious.

FlexSim 21.0.0
flexsim 21.0.0http
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
4 Likes"
Phil BoBo answered Phil BoBo commented

There's no way to currently change that header data, but I'll add a case to the dev list to add a property for header data.

· 7
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Serge A avatar image Serge A commented ·
Is there any progress on this issue? One of our client needs to do PUT requests with custom headers (Content-Type, Accept). Unfortunately, it is still not possible in Flexscript API.
0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Serge A commented ·

I will increase the priority on the card and try to work on this for FlexSim 22.1.

0 Likes 0 ·
Serge A avatar image Serge A Phil BoBo ♦♦ commented ·
Thank you.
0 Likes 0 ·
yexioamu avatar image yexioamu commented ·

Hi, BoBo, can I change the header to 'application/json' now? and my flexsim version is 21.2.4.

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ yexioamu commented ·
The headers property was added to Http.Request in FlexSim 22.1.0. You need to use that version or newer to access it.
0 Likes 0 ·
yexioamu avatar image yexioamu Phil BoBo ♦♦ commented ·

Thank for your answer, i tried the request.headers you suggested in the version 23.05 by using PF, it works well! But due to my company software purchase policy, i can't upgrade my FlexSim version quickly, does it possible that achieve it in version 21.2.4, or can i achieve it by using DLL function? If it is possible, can i get some references from anywhere?

0 Likes 0 ·
Show more comments