Page 1 of 1
content-type application/x-www-form-urlencoded
Posted: Wed Jun 16, 2021 2:47 am
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 ?
Re: content-type application/x-www-form-urlencoded
Posted: Wed Jun 16, 2021 7:37 am
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.
Re: content-type application/x-www-form-urlencoded
Posted: Wed Jun 16, 2021 8:59 am
by Dino
it works!
thank you!
Re: content-type application/x-www-form-urlencoded
Posted: Wed Jun 16, 2021 11:03 am
by BrendanB
Dino,
great, but which one worked for you...
Re: content-type application/x-www-form-urlencoded
Posted: Wed Jun 16, 2021 11:10 am
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 |
----------------------------------------------------------