Question
· Mar 17, 2016

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 .

Discussion (8)0
Log in or sign up to continue

It's for translating response status into Caché status. I have the following code:

ClassMethod GetResponseStatus(Request As %Net.HttpRequest) As %Status
{
    Set Status = Request.HttpResponse.StatusCode
    Quit:(Status = 200) $$$OK
    Set Body = Request.HttpResponse.Data.Read($$$MaxCacheInt)
    Quit $$$ERROR($$$GeneralError,"Status code: " _ Status _ " ReasonPhrase: " _ Request.HttpResponse.ReasonPhrase _ " StatusLine: " _ Request.HttpResponse.StatusLine _ " Body: " _ Body)
}

And I want to add URL reporting to it.