Sending post Request with ContentType:"application/x-www-form-urlencoded"

Hello,
Having difficulty with sending POST request.

How I can send parameters in the body of request, if i'm using ContentType:"application/x-www-form-urlencoded".

Version of ensemble: 2010

My code is bellow:

Set httpRequest=##class(%Net.HttpRequest).%New()
set httpRequest.SSLConfiguration="1"
Set httpRequest.ContentCharset="utf-8"
Set httpRequest.Server="test.oath.com"
Set httpRequest.Port=443
Set httpRequest.Https=1
Set httpRequest.Location = "/auth/key"
set httpRequest.ContentType="application/x-www-form-urlencoded"
Set httpRequest.ContentCharset="utf-8"    
do httpRequest.EntityBody.Write("grant_type=client_credentials&scope=num&client_id=random")
Set httpRequest.Timeout=119
do httpRequest.Post("",2)

the result

User-Agent: Mozilla/4.0 (compatible; Cache;)
Host: test.oath.com
Connection: Close
Accept-Encoding: gzip
Content-Length: 112
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&scope=num&client_id=random

  • 0
  • 0
  • 1371
  • 1
  • 1

Answers