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: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

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

Post by Dino »

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: 134
Joined: Tue Nov 24, 2015 10:29 am

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

Post by BrendanB »

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: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

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

Post by Dino »

it works!

thank you!
BrendanB
Posts: 134
Joined: Tue Nov 24, 2015 10:29 am

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

Post by BrendanB »

Dino,

great, but which one worked for you...
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

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

Post by Dino »

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