SyntaxError in Portal when querying custom GeocodeServer

675
2
01-03-2019 07:00 AM
JonathanBailey
Occasional Contributor III

I've created a custom GeocodeServer according to the ArcGIS Rest API specification. To this point, I've implemented the root (GeocodeServer), findAddressCandidates, and suggest, and referenced the custom GeocodeServer as a utility service in Portal for ArcGIS.

In the Portal map viewer, I've selected the custom GeocodeServer from the Find dropdown list, and enter some text. No suggestions are shown, and, when I press Enter, no candidates are found.

Looking at the console reveals a SyntaxError for both the suggest and findAddressCandidates requests:

Looking at the response from the custom GeocodeServer for a call to suggest:

it appears to have the same syntax as the response from the ArcGIS World Geocoding Service:

The same is true for calls to the findAddressCandidates method. For the custom GeocodeServer:

and for the ArcGIS World Geocoding Service:

I do note, however, that the response headers are somewhat different. For the custom GeocodeServer, a response from suggest has the following response headers:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Content-Encoding: gzip
Expires: -1
Vary: Accept-Encoding
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 03 Jan 2019 14:57:10 GMT

whereas from the ArcGIS World Geocoding Service, the response headers are:

HTTP/2.0 200 OK
date: Thu, 03 Jan 2019 14:58:47 GMT
content-type: application/json;charset=UTF-8
content-length: 331
vary: Origin
access-control-allow-origin: https://devweb.tcgis.ca
access-control-allow-credentials: true
cache-control: max-age=0,must-revalidate
server: 
set-cookie: AGS_ROLES="419jqfa+uOZgYod4xPOQ8Q=="; Version=1; Max-Age=60; Expires=Thu, 03-Jan-2019 14:59:47 GMT; Path=/arcgis/rest; HttpOnly
etag: 73d496d8
content-encoding: gzip
X-Firefox-Spdy: h2

But, I'm not exactly sure which, if any of these, would cause the SyntaxError.

Any ideas appreciated.

0 Kudos
2 Replies
ShanaBritt
Esri Regular Contributor

Jon:

What version is the custom locator and portal you are using?

Which locator style was used to build the locator?

0 Kudos
JonathanBailey
Occasional Contributor III

Hi Shana!

It turns out that there's an "undocumented" "feature" at work here with the REST API. In addition to the documented parameters, there's a `callback` parameter; if the client provides a value for this (which Portal for ArcGIS does), then the service needs to wrap the response in the provided callback. Once I did this, then it worked correctly.

Thanks,

Jon.

0 Kudos