Question
· Sep 20, 2018

HTTP Request - InsertParam method

Hello Experts,

I have a silly question of using InsertParam method and usage. I understand it is name value pair. I am using GET method to send a url and to get the details from server. URL has multiparameter

URL -  api/Identifier/Image/?Verify.EDD={EDD}&Verify.Ethnicity={ETHNICITY}

I have used the URL in a method and called that method directly in the business operation. I am using Insertparam method -

do httpRequest.InsertParam("EDD",..Data.Verify.EDD)
do httpRequest.InsertParam("ETHNICITY",..Data.Verify.Ethnicity)

where httpRequest is an object of %Net.HttpRequest class

Question is how will these parameters can be called in the URL? Please advice

Is there any other ways we can do the same things? Ultimately, i want to pass these parameters in the url

Discussion (1)1
Log in or sign up to continue

The documentation for %Net.HttpRequest has some sample code that should be useful:

From that page:

In order to send parameters on the URL, i.e. when you see a URL like

http://www.demo.com/page.html?PARAM1=TEST&PARAM2=HELLO

You use the SetParam method to add these parameters one by one. For example to get the index page from 
Documatic you do:

    Set httprequest=##class(%Net.HttpRequest).%New()
    Set httprequest.Port=1972
    Do httprequest.SetParam("PAGE","INDEX")
    Do httprequest.Get("/csp/docbook/%CSP.Documatic.cls")
    Do httprequest.HttpResponse.OutputToDevice()

You may also pass the query parameters on the Get call directly too as long as they are correctly escaped.