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

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
User avatar
Dino
Posts: 134
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

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

Post by Dino » Wed Jun 16, 2021 2:47 am

Hi

Any suggestion how to change the content-type in a request using #XPRIM_HttpRequest from application/json to application/x-www-form-urlencoded ?

BrendanB
Posts: 57
Joined: Tue Nov 24, 2015 10:29 am

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

Post by BrendanB » Wed Jun 16, 2021 7:37 am

Dino,

you could try:

#HttpRequest.Content.ContentInfo.MediaType := 'application/x-www-form-urlencoded'

If that doesnt do it,

#httpRequest.Options.AddHeader Name('Content-Type') Value('application/x-www-form-urlencoded')

might also work.

User avatar
Dino
Posts: 134
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

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

Post by Dino » Wed Jun 16, 2021 8:59 am

it works!

thank you!

BrendanB
Posts: 57
Joined: Tue Nov 24, 2015 10:29 am

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

Post by BrendanB » Wed Jun 16, 2021 11:03 am

Dino,

great, but which one worked for you...

User avatar
Dino
Posts: 134
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

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

Post by Dino » Wed Jun 16, 2021 11:10 am

The first one:

Code: Select all

Define_Com Class(#XPRIM_HttpRequest) Name(#Request)
(....)
#Request.Content.ContentInfo.MediaType := 'application/x-www-form-urlencoded'
#Request.DoPost Url(#Url)
request.headers.log reports:
----------------------------------------------------------
| | HEADER NAME | HEADER VALUE |
----------------------------------------------------------
| 1 | Content-Length | 143 |
| 2 | Content-Type | application/x-www-form-urlencoded |
| 3 | User-Agent | cpprestsdk/2.10.14 |
----------------------------------------------------------

Post Reply