Question Token Ibragimov · Aug 8, 2019

Sending Get request

Hello! I'm sending get request. When send the request bellow 

Set httprequest=##class(%Net.HttpRequest).%New()
Set httprequest.Server=url
Do httprequest.Get("/"_par1_"/"_par2)
 Set statusCode = httprequest.HttpResponse.StatusCode

I get http status 200, but should get 410 status. Since the parameters passed are not valid. 

If I send request differently as below, I get http status 410, which is correct. 

Do httprequest.Get("/2019/0912")

What is the difference between these two requests Do httprequest.Get("/"_par1_"/"_par2) and Do httprequest.Get("/2019/0912")?

Comments

Dmitry Maslennikov · Aug 8, 2019

Remember about the second parameter in methods like Get and Post, which named test, which you can use for debugging purposes.

 If test is 1 then instead of connecting to a remote machine it will just output what it would have send to the web server to the current device, if test is 2 then it will output the response to the current device after the Get. This can be used to check that it will send what you are expecting.

0
Robert Cemper · Aug 8, 2019

did you verify if  par2 is really "0912" (leading zero) and not just 912

0
Token Ibragimov  Aug 8, 2019 to Robert Cemper

Thank you!

You are right, I checked the request, zeros are not displayed. How to send zeros in request ?

GET /201506/91001?PAGE=INDEX HTTP/1.1

must be

/201506/091001

0
Dmitry Maslennikov  Aug 8, 2019 to Token Ibragimov

You already using concatenation, it, means, that you lost leading zero, somewhere before. You may have some arithmetic operations with your parameters, which will case to lose those zeros.

0
Sourabh Sethi · Aug 8, 2019

You can try $$$URLENCODE the complete url.

0
Jenna Makin · Aug 8, 2019

is it possible that "par1" and "par2" don't contain the values you think they do.  I would start there and confirm that par1 = "2019" and par2 = "0912"

Jenna

0