Skip to content

What is a REST based scripting workflow for publishing geocoding services?

Doug Carroll edited this page Apr 25, 2015 · 2 revisions

Scripting a the creation of a Geocode Service

There are various ways to script the creation of a service. The most popular workflow is to use ArcPy scripts and upload a Service Definition file. However a REST based option exists too. This involves 1) Authentication using an Admin credential and 2) Passing the proper JSON payload to /arcgis/admin/services/createService using a POST. Before scripting the workflow developers can test the JSON payload directly though the createService webform.

Example REST request

/POST /arcgis/admin/services/createService


{
 "serviceName": "MyAddressLocator",
 "type": "GeocodeServer",
 "description": "Atlanta Locator Testing",
 "capabilities": "Geocode,ReverseGeocode",
 "provider": "ArcObjects",
 "interceptor": "",
 "clusterName": "default",
 "minInstancesPerNode": 1,
 "maxInstancesPerNode": 2,
 "instancesPerContainer": 1,
 "maxWaitTime": 60,
 "maxStartupTime": 300,
 "maxIdleTime": 1800,
 "maxUsageTime": 600,
 "loadBalancing": "ROUND_ROBIN",
 "isolationLevel": "HIGH",
 "configuredState": "STARTED",
 "recycleInterval": 24,
 "recycleStartTime": "00:00",
 "keepAliveInterval": 1800,
 "private": false,
 "isDefault": false,
 "maxUploadFileSize": 0,
 "allowedUploadFileTypes": "",
 "properties": {
  "outputDir": "/net/SITEHOST/gisdata/arcgisserver/directories/arcgisoutput",
  "virtualOutputDir": "/rest/directories/arcgisoutput",
  "locator": "MyAddressLocator",
  "suggestedBatchSize": "1000",
  "minScale": "-1",
  "textAntialiasingMode": "Force",
  "antialiasingMode": "None",
  "maxScale": "-1",
  "maxResultSize": "500",
  "locatorWorkspacePath": "/gisdata/data\\Geocoding\\Locators\\",
  "maxBatchSize": "1000"
 },
 "extensions": [],
 "datasets": []
}

Note the file pathes in the above JSON parameters were targeting an ArcGIS for Server Linux setup. The locator (.loc file) was MyAddressLocator. The locator workspace property is locatorWorkspacePath and it represents the path to the locator found on disk here /gisdata/data/Geocoding/Locators.

Lastly, when sending this createService request using code it's important to remember that an Admin Token need to be appended to the request parameters.

ex

token=sdfsdfsdfsdfsdfasfgfdgfd