feature
Inputs with feature data type can be specified using a JSON structure that represents the features.
You can either specify the complete input using json, or you can publish the input as a feature service or map service and specify the URL of the feature service or map service layer as the input.
- The example shows a last mile delivery service's order input feature. Refer to each feature input's documentation for the supported attributes for each feature.
{
"spatialReference": {
"wkid": "<wkid>",
"latestWkid": "<wkid>"
},
"features": [
{
"geometry": {
"x": "<x1>",
"y": "<y1>"
},
"attributes": {
"<field1>": "<value11>",
"<field2>": "<value12>"
}
},
{
"geometry": {
"x": "<x2>",
"y": "<y2>"
{
"url": "<url>"
}
POST https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/Routing/NetworkAnalysis/GPServer/SolveLastMileDelivery/submitJob HTTP/1.1
Content-Type: application/x-www-form-urlencoded
token=<ACCESS_TOKEN>
&f=json
&orders={
"features": [
{
"geometry": {
"x": -117,
"y": 34
},
"attributes": {
"Name": "Order 1",
"ServiceTime": 5,
"TimeWindowStart": null,
"TimeWindowEnd": 1706868000000,
"MaxViolationTime": 0,
"DeliveryQuantity_1": 2000,
"DeliveryQuantity_2": 100
table
Inputs with table data type can be specified using a JSON structure that represents the records.
You can either specify the complete input using json, or you can publish the input as a feature service or map service and specify the URL of the table layer within the feature service or map service as the input.
- The example shows a last mile delivery service's routes input feature. Refer to each feature input's documentation for the supported attributes for each feature.
{
"features": [
{
"attributes": {
"<field1>": "<value11>",
"<field2>": "<value12>"
}
},
{
"attributes": {
"<field1>": "<value21>",
"<field2>": "<value22>"
}
}
]
}
{
"url": "<url>"
}
POST https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/Routing/NetworkAnalysis/GPServer/SolveLastMileDelivery/submitJob HTTP/1.1
Content-Type: application/x-www-form-urlencoded
token=<ACCESS_TOKEN>
&f=json
&orders={
"features": [
{
"geometry": {
"x": -117,
"y": 34
},
"attributes": {
"Name": "Order 1",
"ServiceTime": 5,
"TimeWindowStart": null,
"TimeWindowEnd": 1706868000000,
"MaxViolationTime": 0,
"DeliveryQuantity_1": 2000,
"DeliveryQuantity_2": 100
datetime
Datetime data type is specified as milliseconds since epoch for the date and time. For example, 1451606400000
represents 01/01/2016 00:00:00
.
date
Date data type is specified as YYYY-MM-DD. For example: 2023-03-15.
time
Time data type is specified as hh:mm:ss, for example: 14:30:30.
travel_mode_object
Travel modes are managed in ArcGIS Enterprise and can be configured by the administrator of your organization to better reflect the organization's workflows.
You must specify the JSON object containing the settings for a travel mode supported by your organization. For a list of supported travel modes, run the Get
tool from the Utilities service.
The value for the travel_
parameter should be a JSON object representing travel mode settings. When you use the Get
from the Utilities service, a string representing the travel mode JSON is returned. You need to convert this string to a valid JSON object using your API, and pass the JSON object as the value for the travel_mode parameter.
The response below is returned by the Get
tool.
{
"results": [
{
"paramName": "supportedTravelModes",
"dataType": "GPRecordSet",
"value": {
"displayFieldName": "",
"fields": [
{
"name": "ObjectID",
"type": "esriFieldTypeOID",
"alias": "ObjectID"
},
{
"name": "Name",
"type": "esriFieldTypeString",
"alias": "Travel Mode Name",
"length": 255
},
{
From the response above, the following is a string representing the Walking Time travel mode:
"{\"attributeParameterValues\": [{\"attributeName\": \"Avoid Private Roads\", \"parameterName\": \"Restriction Usage\", \"value\": \"AVOID_MEDIUM\"}, {\"attributeName\": \"Walking\", \"parameterName\": \"Restriction Usage\", \"value\": \"PROHIBITED\"}, {\"attributeName\": \"Preferred for Pedestrians\", \"parameterName\": \"Restriction Usage\", \"value\": \"PREFER_LOW\"}, {\"attributeName\": \"WalkTime\", \"parameterName\": \"Walking Speed (km/h)\", \"value\": 5}, {\"attributeName\": \"Avoid Roads Unsuitable for Pedestrians\", \"parameterName\": \"Restriction Usage\", \"value\": \"AVOID_HIGH\"}], \"description\": \"Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.\", \"distanceAttributeName\": \"Kilometers\", \"id\": \"caFAgoThrvUpkFBW\", \"impedanceAttributeName\": \"WalkTime\", \"name\": \"Walking Time\", \"restrictionAttributeNames\": [\"Avoid Private Roads\", \"Avoid Roads Unsuitable for Pedestrians\", \"Preferred for Pedestrians\", \"Walking\"], \"simplificationTolerance\": 2, \"simplificationToleranceUnits\": \"esriMeters\", \"timeAttributeName\": \"WalkTime\", \"type\": \"WALK\", \"useHierarchy\": false, \"uturnAtJunctions\": \"esriNFSBAllowBacktrack\"}"
The value above should be converted to a valid travel mode JSON object and passed as the value for the travel_mode parameter as shown below.
{
"attributeParameterValues": [
{
"attributeName": "Avoid Private Roads",
"parameterName": "Restriction Usage",
"value": "AVOID_MEDIUM"
},
{
"attributeName": "Walking",
"parameterName": "Restriction Usage",
"value": "PROHIBITED"
},
{
"attributeName": "Preferred for Pedestrians",
"parameterName": "Restriction Usage",
"value": "PREFER_LOW"
},
{
"attributeName": "WalkTime",
"parameterName": "Walking Speed (km/h)",
locate_settings_object
This object is used to specify settings that affect how inputs are located, such as the maximum search distance to use when locating the inputs on the network or the network sources being used for locating.
To restrict locating on a portion of the source, you can specify a where clause for a source. Learn more about locating inputs
The locate settings object is specified as a JSON object. The JSON object allows you to specify a locator JSON for all input feature in the analysis, or you can specify an override for a particular input. The override allows you to have different settings for each analysis input. For example, you can disallow stops to locate on highway ramps and allow point barriers to locate on highway ramps.
The locator JSON object has the following properties:
-
tolerance
andtolerance
—Control the maximum search distance when locating inputs. If no valid network location is found within this distance, the input features will be considered unlocated. A small search tolerance decreases the likelihood of locating on the wrong street but increases the likelihood of not finding a valid network location. TheUnits tolerance
parameter value can be specified as one of the following values:Units esri
Centimeters esri
Decimal Degrees esri
Decimeters esri
Feet esri
Inches esri
I n t Feet esri
I n t Inches esri
I n t Miles esri
I n t Nautical Miles esri
I n t Yards esri
Kilometers esri
Meters esri
Miles esri
Millimeters esri
Nautical Miles esri
Yards
-
sources
—Control which network source can be used for locating. For example, you can configure the analysis to locate inputs on streets but not on sidewalks. The list of possible sources on which to locate is specific to the network dataset this service references. Only the sources that are in the sources array are used for locating. You can specify awhere
clause on each source you specified in the sources array to further restrict locating on that source matching certain characteristics using an SQL expression. For example, you can configure the analysis to locate inputs only on street features matching certain road classes such as avoiding highway ramps.sources
is specified as an array of objects, each having the following properties:name
—The name of the network source feature class that can be used for locating inputs.where
—An SQL expression on the network source feature class.
-
allow
—Control whether inputs with existing network location fields can be automatically relocated when solving to ensure valid, routable location fields for the analysis. If the value isAuto Relocate true
, points located on restricted network elements and points affected by barriers will be relocated to the closest routable location. If the value isfalse
, network location fields will be used as they are even if the points are unreachable, and this may cause the solve to fail. Even if the value isfalse
, inputs with no location fields or incomplete location fields will be located during the solve operation.
The following is the syntax for locating settings using a JSON structure:
{
"default": {
"tolerance": "<value>",
"toleranceUnits": "<unit>",
"allowAutoRelocate": "true | false",
"sources": [
{
"name": "<sourceName>",
"where": "<whereClause>"
}
]
},
"overrides": {
"orders": {
"tolerance": "<value>",
"toleranceUnits": "<unit>",
"allowAutoRelocate": "true | false",
"sources": [
{
"name": "<sourceName>",
usage_cost_object
The usage_
object is returned as a JSON with the following syntax:
{
"paramName": "Usage_Cost",
"dataType": "GPString",
"value": {
"numObjects": "<number>",
"credits": "<number>"
}
}
Example for usage_cost
The following shows an example of the usage_cost parameter in which the analysis generated 9 billable objects (represented by numObjects) and 4.5 credits were used by the analysis.
{
"paramName": "Usage_Cost",
"dataType": "GPString",
"value": {
"numObjects": 9,
"credits": 4.5
}
}
context_object
The Context object contains the following additional settings that affect task operation:
- Extent (
extent
)—A bounding box that defines the analysis area. Only input features that intersect the bounding box will be analyzed. - Output spatial reference (
out
)—The output features will be projected into the output spatial reference.S R
file
Outputs with file data type are returned as a JSON structure with a url field. The value of the url field is a URL to the location of the output file.
By default, these files will no longer be available when directories get cleaned up periodically. To learn more about these directories, and configure the frequency of the cleanup, see Server directories
{
"paramName": "<paramName>",
"dataType": "GPDataFile",
"value": {
"url": "<url>"
}
}