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
I would use the InsertFormData() method on the HttpRequest object. There's an example in the class reference:
https://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls
Hello Sir,
I can see that you are calling api of Sciener Open Platform. I also need to implement the same. I only need to implement the Web API. And I can see that first we have to create an user that I created. But How can I create a company and how can I get the client_id and client_secret? Can you please suggest me? I appreciate your help.
Thank You.