Service request types

The ArcGIS Geocoding service supports two different types of requests: Direct request or Job request. Each type of request returns exactly the same results the difference is how the request is made and how the results are obtained. The method you use depends on the complexity of your task, the expected processing time and the size of the data involved.

This section provides information about the different types of requests, their capabilities, and when to use them.

Direct requests

A direct request is a single HTTPS request to a service for a transaction that typically has a short duration.

Use a direct request when:

  • The data and number of parameters you are sending to the service is small in size.
  • You want results returned in the response from a single operation.
  • You want results returned quickly, typically under a few seconds.
  • You do not need to cancel a request or perform periodic status checks.

Example

The general steps to perform a direct request are:

  1. Select the request.
  2. Supply the appropriate parameters.
  3. Make the request. 1.Access the results.
Request
cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
4
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates \
-d "f=pjson" \
-d "address=1600 Pennsylvania Ave NW, DC" \
-d "token=<ACCESS_TOKEN>"
Response
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{
  "spatialReference": {
    "wkid": 4326,
    "latestWkid": 4326
  },
  "candidates": [
    {
      "address": "1600 Pennsylvania Ave NW, Washington, District of Columbia, 20500",
      "location": {
        "x": -77.036548499999995,
        "y": 38.89767599999999
      },
      "score": 100,
      "attributes": {
        "Loc_name": "World",
        "Status": "M",
        "Score": 100,
        "Match_addr": "1600 Pennsylvania Ave NW, Washington, District of Columbia, 20500",
        "LongLabel": "1600 Pennsylvania Ave NW, Washington, DC, 20500, USA",
        "ShortLabel": "1600 Pennsylvania Ave NW",
        "Addr_type": "PointAddress",
        "Type": "",
        "PlaceName": "",
        "Place_addr": "1600 Pennsylvania Ave NW, Washington, District of Columbia, 20500",
        "Phone": "",
        "URL": "",
        "Rank": 20,
        "AddBldg": "",
        "AddNum": "1600",
        "AddNumFrom": "",
        "AddNumTo": "",
        "AddRange": "",
        "Side": "",
        "StPreDir": "",
        "StPreType": "",
        "StName": "Pennsylvania",
        "StType": "Ave",
        "StDir": "NW",
        "BldgType": "",
        "BldgName": "",
        "LevelType": "",
        "LevelName": "",
        "UnitType": "",
        "UnitName": "",
        "SubAddr": "",
        "StAddr": "1600 Pennsylvania Ave NW",
        "Block": "",
        "Sector": "",
        "Nbrhd": "",
        "District": "",
        "City": "Washington",
        "MetroArea": "",
        "Subregion": "District of Columbia",
        "Region": "District of Columbia",
        "RegionAbbr": "DC",
        "Territory": "",
        "Zone": "",
        "Postal": "20500",
        "PostalExt": "",
        "Country": "USA",
        "LangCode": "ENG",
        "Distance": 0,
        "X": -77.036548499999995,
        "Y": 38.89767599999999,
        "DisplayX": -77.036548499999995,
        "DisplayY": 38.89767599999999,
        "Xmin": -77.0375485,
        "Xmax": -77.03554849999999,
        "Ymin": 38.896675999999992,
        "Ymax": 38.898675999999988,
        "ExInfo": ""
      },
      "extent": {
        "xmin": -77.0375485,
        "ymin": 38.896675999999992,
        "xmax": -77.03554849999999,
        "ymax": 38.898675999999988
      }
    }
  ]
}

Error handling

When performing a direct request, the response object will contain the results of the request if the response is successful. If the request failed, an error object with HTTP status code and optionally extendedCode values will be returned.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
{
  "error": {
    "code": 400,
    "extendedCode": -2147024809,
    "message": "Invalid or missing input parameters.",
    "details": ["Layer [Route_(null)] could not be found in the map or is of the wrong type."]
  }
}

In some cases the response will be successful, but partial results may be returned. In these cases the messages array will contain pertinent information regarding the status of the results.

Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  "messages": [
    {
      "type": "informative",
      "description": "Some stops could not be reached"
    }
  ]
}

Job requests

A job request is an HTTPS request to a service that starts a server-side operation (or job) with a long duration. A job request returns a job ID that is used by client applications to make subsequent HTTPS requests to determine job status updates and, when it is complete, to download the final job output.

Use a job request when:

  • Your problem involves significant time to process, such as large scale geoprocessing or complex spatial analysis.
  • You want to monitor the status of long running transactions and retrieve the results when they are ready.
  • You have a large long-running task and don't want time outs.
  • You want to submit multiple jobs simultaneously, allowing for efficient processing of multiple tasks without waiting for one to complete before starting another.

The general steps to perform a job request are:

  1. Make a submitJob request with the appropriate parameters to get a jobId.
  2. Using the jobId, make periodic requests to check until jobStatus returned is esriJobSucceeded | esriJobFailed | esriJobTimedOut.
    • To cancel a job you can append /cancel to the request url.
  3. Use the jobId to get one or more results.

Example

Request
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

POST https://geocode-beta.arcgis.com/arcgis/rest/services/World/GeocodeServer/batchGeocode/beta/submitJob HTTP/1.1
content-type: application/x-www-form-urlencoded
User-Agent: {USER_AGENT}

item = {'itemID': '{ITEM_ID}'}
&token={ACCESS_TOKEN}
&fieldMapping=Address:street_address,City:municipality,Region:state,Postal:zip_code
&outFields='*'
Response
Use dark colors for code blocksCopy
1
2
3
4
5
{
  "jobId": "{JOB_ID}",
  "jobStatus": "{esriJobSubmitted | esriJobWaiting | esriJobExecuting | esriJobSucceeded | esriJobFailed | esriJobTimedOut | esriJobCancelling | esriJobCancelled}",
  "messages": []
}

Error handling

The workflow for performing a job request is a multi-step process. For each step in the process (Submit job, Check status, Get results) a response object is returned. If there are issues related to accessing the job, an error object will be returned containing an error code and in some cases an additional extendedCode value.

Example error object with HTTP status code:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
{
  "error": {
    "code": 499,
    "message": "Token Required",
    "details": []
  }
}

Example error with HTTP status code and extendedCode:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
{
  "error": {
    "code": 400,
    "extendedCode": -2147220218,
    "message": "Job not found on server.",
    "details": ["JobId not found : null. "]
  }
}

If the job failed, the jobStatus will be esriJobFailed and the messages array will contain pertinent information regarding the status of the job.

Example response for a failed job:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "jobId": "{JOB_ID}",
  "jobStatus": "esriJobFailed",
  "messages": [
    {
      "type": "esriJobMessageTypeInformative",
      "description": "Submitted."
    },
    {
      "type": "esriJobMessageTypeInformative",
      "description": "Executing..."
    },
    {
      "type": "esriJobMessageTypeWarning",
      "description": "Location \"O2\" in \"Stops\" is unlocated."
    },
    {
      "type": "esriJobMessageTypeWarning",
      "description": "Need at least 2 valid stops."
    },
    {
      "type": "esriJobMessageTypeError",
      "description": "ERROR 030024: Solve returned a failure."
    },
    {
      "type": "esriJobMessageTypeError",
      "description": "\"Stops\" does not contain valid input for any route."
    },
    {
      "type": "esriJobMessageTypeError",
      "description": "Failed to execute (FindRoutes)."
    },
    {
      "type": "esriJobMessageTypeError",
      "description": "Failed."
    }
  ]
}

If the job succeeded, the jobStatus will be esriJobSucceeded, the messages array may still contain pertinent information regarding the status of the job, especially if there are warning messages.

Example response for a successful job with warning messages:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
{
  "jobId": "{JOB_ID}",
  "jobStatus": "esriJobSucceeded",
  "results": {
    "Solve_Succeeded": {
      "paramUrl": "results/Solve_Succeeded"
    },
    "Output_Routes": {
      "paramUrl": "results/Output_Routes"
    },
    "Output_Route_Edges": {
      "paramUrl": "results/Output_Route_Edges"
    },
    "Output_Directions": {
      "paramUrl": "results/Output_Directions"
    },
    "Output_Stops": {
      "paramUrl": "results/Output_Stops"
    },
    "Output_Network_Analysis_Layer": {
      "paramUrl": "results/Output_Network_Analysis_Layer"
    },
    "Output_Route_Data": {
      "paramUrl": "results/Output_Route_Data"
    },
    "Output_Result_File": {
      "paramUrl": "results/Output_Result_File"
    },
    "Output_Network_Analysis_Layer_Package": {
      "paramUrl": "results/Output_Network_Analysis_Layer_Package"
    },
    "Output_Direction_Points": {
      "paramUrl": "results/Output_Direction_Points"
    },
    "Output_Direction_Lines": {
      "paramUrl": "results/Output_Direction_Lines"
    },
    "Usage_Cost": {
      "paramUrl": "results/Usage_Cost"
    }
  },
  "inputs": {
    "Stops": {
      "paramUrl": "inputs/Stops"
    },
    "Measurement_Units": {
      "paramUrl": "inputs/Measurement_Units"
    },
    "Reorder_Stops_to_Find_Optimal_Routes": {
      "paramUrl": "inputs/Reorder_Stops_to_Find_Optimal_Routes"
    },
    "Preserve_Terminal_Stops": {
      "paramUrl": "inputs/Preserve_Terminal_Stops"
    },
    "Return_to_Start": {
      "paramUrl": "inputs/Return_to_Start"
    },
    "Use_Time_Windows": {
      "paramUrl": "inputs/Use_Time_Windows"
    },
    "Time_Zone_for_Time_of_Day": {
      "paramUrl": "inputs/Time_Zone_for_Time_of_Day"
    },
    "UTurn_at_Junctions": {
      "paramUrl": "inputs/UTurn_at_Junctions"
    },
    "Point_Barriers": {
      "paramUrl": "inputs/Point_Barriers"
    },
    "Line_Barriers": {
      "paramUrl": "inputs/Line_Barriers"
    },
    "Polygon_Barriers": {
      "paramUrl": "inputs/Polygon_Barriers"
    },
    "Use_Hierarchy": {
      "paramUrl": "inputs/Use_Hierarchy"
    },
    "Restrictions": {
      "paramUrl": "inputs/Restrictions"
    },
    "Attribute_Parameter_Values": {
      "paramUrl": "inputs/Attribute_Parameter_Values"
    },
    "Route_Shape": {
      "paramUrl": "inputs/Route_Shape"
    },
    "Route_Line_Simplification_Tolerance": {
      "paramUrl": "inputs/Route_Line_Simplification_Tolerance"
    },
    "Populate_Route_Edges": {
      "paramUrl": "inputs/Populate_Route_Edges"
    },
    "Populate_Directions": {
      "paramUrl": "inputs/Populate_Directions"
    },
    "Directions_Language": {
      "paramUrl": "inputs/Directions_Language"
    },
    "Directions_Distance_Units": {
      "paramUrl": "inputs/Directions_Distance_Units"
    },
    "Directions_Style_Name": {
      "paramUrl": "inputs/Directions_Style_Name"
    },
    "Travel_Mode": {
      "paramUrl": "inputs/Travel_Mode"
    },
    "Impedance": {
      "paramUrl": "inputs/Impedance"
    },
    "Time_Zone_for_Time_Windows": {
      "paramUrl": "inputs/Time_Zone_for_Time_Windows"
    },
    "Save_Output_Network_Analysis_Layer": {
      "paramUrl": "inputs/Save_Output_Network_Analysis_Layer"
    },
    "Save_Route_Data": {
      "paramUrl": "inputs/Save_Route_Data"
    },
    "Time_Impedance": {
      "paramUrl": "inputs/Time_Impedance"
    },
    "Distance_Impedance": {
      "paramUrl": "inputs/Distance_Impedance"
    },
    "Output_Format": {
      "paramUrl": "inputs/Output_Format"
    },
    "Ignore_Invalid_Locations": {
      "paramUrl": "inputs/Ignore_Invalid_Locations"
    },
    "Locate_Settings": {
      "paramUrl": "inputs/Locate_Settings"
    }
  },
  "messages": [
    {
      "type": "esriJobMessageTypeWarning",
      "description": "Location \"O3\" in \"Stops\" is unlocated."
    },
    {
      "type": "esriJobMessageTypeWarning",
      "description": "WARNING 030025: Partial solution generated."
    }
  ]
}

HTTP Operations

Most ArcGIS Services support making requests as either a GET or POST. Below is a table describing the key differences between each:

FeatureGETPOST
PurposeRetrieve data from a server, peform search queriesSend data to a server or update server state such as Form submissions, file uploads, and data updates
DataVisible in URL parametersSent in request body
SecurityLess secure, data visible in URL. Parameters remain in browser historyMore secure, data not visible in URL. Parameters are not saved in browser history
CachingCan be cachedNot typically cached
BookmarkingCan be bookmarkedCannot be bookmarked
Data lengthLimited by URL length (typically 2048 characters)No restrictions
Data typesOnly supports string dataSupport various data type (string, numeric, binary)
Encodingapplication/x-www-form-urlencodedapplication/x-www-form-urlencoded or multipart/form-data

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.