Select to view content in your preferred language

ArcGis locator task vs REST call has different results

620
3
Jump to solution
08-09-2022 08:34 AM
JulianBissekkou
Emerging Contributor

I am using the android and iOS sdks to perform a geocode request to the server. When I am calling the same endpoint using REST I get different results back.

In my case the REST call has more results.

iOS code:

        let locatorTask = AGSLocatorTask(url: URL(string: "https://my-server/services/GeocodeServer/")!)
        
        let params = AGSGeocodeParameters()
        params.maxResults = payload.maxSuggestions
        params.countryCode = "DE"
        params.outputSpatialReference = .wgs84()
        params.resultAttributeNames = ["*"]

        locatorTask.geocode(withSearchText: payload.searchQuery, parameters: params) {
          // handle result
        }

REST call:

https://my-server/services/GeocodeServer/suggest?f=json&text=SomeStreet

It would be nice to know what request url the iOS lib generates.

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

You can use AGSRequestConfiguration to log some debug info to the console. Try something like this:

let locatorTask = AGSLocatorTask(url: URL(string: "https://my-server/services/GeocodeServer/")!)

if let gc = AGSRequestConfiguration.global().copy() as? AGSRequestConfiguration {
    gc.debugLogRequests = true
    locatorTask.requestConfiguration = gc
}

That should output the request for you.

Please note that you should not log this debug info in a release version of your app. There is a performance hit to this logging and you should disable it in production and testing.

View solution in original post

0 Kudos
3 Replies
Nicholas-Furness
Esri Regular Contributor

You can use AGSRequestConfiguration to log some debug info to the console. Try something like this:

let locatorTask = AGSLocatorTask(url: URL(string: "https://my-server/services/GeocodeServer/")!)

if let gc = AGSRequestConfiguration.global().copy() as? AGSRequestConfiguration {
    gc.debugLogRequests = true
    locatorTask.requestConfiguration = gc
}

That should output the request for you.

Please note that you should not log this debug info in a release version of your app. There is a performance hit to this logging and you should disable it in production and testing.

0 Kudos
JulianBissekkou
Emerging Contributor

Thanks! I was able to take a look at the request and I noticed that the client sdk uses a different query param.

It adds `findAddressCandidates?`, `&outSR`, `&forStorage` and `&SingleLine` but the REST calls works fine with just `&text=`.

I would like to only send `&text` and nothing else.

 

Are we able to configure that?

0 Kudos
JulianBissekkou
Emerging Contributor

Okay I think i missed the "suggest" method of the locatorTask that does exactly what I thought.

My question is: Why is there a "suggest" api when we can also search for points using geocode?

0 Kudos