How send request without urlencode params in URI?
Hello!
I send request:
set hr=##class(%Net.HttpRequest).%New()
set hr.Server = "server.com"
set hr.Location = "method?param=value"
do hr.EntityBody.Write("{ "name": "value" }")
set tSC=hr.Send("POST")
But when request incoming to server.com URI = "method%3Fparam%3Dvalue".
How I can disable urlencode params in URI, so that the URI remains "method?param=value"?
Comments
set hr=##class(%Net.HttpRequest).%New()
set hr.Server = "server.com"
set hr.Location = "method"
do hr.SetParam("name","value")
Thanks, Jeffrey.
I don't know why, but in this case the parameters are lost.
[HTTP SERVER] post /method
And it should be [HTTP SERVER] post /method?name=value
Oops, instead of hr.SetParam() try hr.InsertFormData("name","value").
This works for me:
USER>set req=##class(%Net.HttpRequest).%New()
USER>set req.Server = "blah.org"
USER>do req.SetParam("name","value")
USER>do req.Post("method",1,0) // 2nd param is output to current device; 3rd is no reset
POST /method?name=value HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; InterSystems IRIS;)
Host: blah.org
Accept-Encoding: gzip
Content-Length: 0Does not work for me. Tried it yet do hr.InsertParam("name1", "value1"). But still the parameters are lost
I'm very sorry, but I was checking incoming requests incorrectly.
And your first answer was what I needed.
Thank you very much for your help!
set hr=##class(%Net.HttpRequest).%New()
set hr.Server = "server.com"
set hr.Location = "method"
do hr.InsertParam("name","value")
do hr.InsertParam("name2","value2")
do hr.Post("",1)And the result
USER>do ^test POST /method?name=value&name2=value2 HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; InterSystems IRIS;) Host: server.com Accept-Encoding: gzip Content-Length: 0
Jeffrey
USER>do req.Post("method",1,0) // 2nd param is output to current device; 3rd is no reset
Dmitry
do hr.Post("",1)
This parameter of the method was not enough for me for testing, I did not think of using it because of my little experience.
Thank you very much!
And the parameters in the Location property are really urlencode by default (%Net.HttpRequest):
Property Location As %String;Method LocationSet(val As %String) As %Status [ Internal ]
{
Set i%Location=$zconvert(val,"O","URL")
Quit $$$OK
}