How to get full URL from %Net.Request object after request
I have a %Net.Request object and I want to get a full URL of the request sent (preferably after all redirects, but even full initial one would be good). For example, I have the following method:
ClassMethod GetBingRequest() As %Net.HttpRequest
{
#dim request As %Net.HttpRequest
set request = ##class(%Net.HttpRequest).%New()
set request.Server = "api.datamarket.azure.com"
set request.Https = $$$YES
set request.SSLConfiguration = "Bing"
set request.Username = ..GetBingAPIKey()
set request.Password = ..GetBingAPIKey()
set request.Location = "Data.ashx/Bing/SearchWeb/v1/Composite"
do request.SetParam("$top", 1)
do request.SetParam("$format", "JSON")
quit request
}
And I invoke it with the method:
ClassMethod Get(Query As %String) {
set request = ..GetBingRequest()
do request.SetParam("Query", "'" _ Query _ "'")
do request.Get()
}
How can I get the full URL of where the request went?
P.S. This is a working code for Bing Search API – Web Results Only .
#dim url = request.Server_":"_request.Port_"/"_request.Location
Or do you mean something else?
There is more to URL then just that. For example:
I'd suggest something like this, after calling Get:
Actually - if you're going to do this after issuing the Get, you should use request.Get(,,0), then do this, then call Reset() on the request manually. Otherwise the parameters will get cleared out and the query string will always be blank.
Thanks. I thought it would be something like this, but hoped there was a system method somewhere.
Yeah, that would be nice to have. I looked a bit and didn't see one right away. (I'd actually been wondering the same thing last night, as it happens.)
Why do you need this?
For example, for debugging purposes you might use second argument of Get method:
In that case "instead of connecting to a remote machine httprequest will just output what it would have send to the web server to the current device".
It's for translating response status into Caché status. I have the following code:
And I want to add URL reporting to it.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue