Apply Edits

Description

License:

The ArcGIS Pipeline Referencing for Server extension is required to use this resource.

Applies a batch of changes (adds, updates, deletes) to the editable LRS layers within the service.

Editing is supported only for multi-user (enterprise and workgroup) geodatabases. File and personal geodatabases do not support web editing.

Currently, only point and linear event layers can be edited. Network (route) layers have read-only access through the service.

Edits may only be applied to event feature classes that are local to the LRS geodatabase. External event tables are treated as read-only data sources and do not support web editing.

All edits sent within one request are applied within a single database transaction to maintain data integrity. If any of the individual edits fails, the entire transaction is rolled back and none of the changes are applied. An edit operation may only include layers that exist within a single database workspace. An error message is returned if an edit request specifies more than one layer and those layers are defined in different workspaces.

Request Parameters

ParameterDetails
f

Description: The response format. The default response is html.

Values: html | json

edits

Required

Description: A batch of changes to apply to the editable layers within the service. Each layer can receive a distinct set of adds, updates, and deletes. The format of the change records depends on the layer type being edited. Event records contain only attributes (including measure values), but no geometry, and the attribute names are case sensitive.

Merge behavior for linear events: The allowMerge option can be set to true or false for each layer being edited. The default is false. If set to true for a linear event layer, each added record is inspected to determine if it can be merged with any existing event record associated with the same route. Merging two records is possible only if their measure ranges are coincident or overlapping, and all other attribute values are the same. This behavior applies only to additions, not updates or deletions.

Retire Overlap behavior for linear events: The retireMeasureOverlap option can be set to true or false for each layer being edited. The default is false. If set to true for a linear event layer, each added record is inspected to determine if it overlaps the measure range of any events associated with the same route. The overlapping portions of any existing events will be retired, which entails updating the To Date field value for that record. This behavior applies only to additions, not updates or deletions.

Retire by Event ID behavior: The retireByEventId option can be set to true or false for each layer being edited. The default is false. If set to true for a point or linear event layer, any existing event records with the same Event ID and temporality overlaps as the added record will be retired.

If an event layer is configured to store referent locations for each event record, the allowMerge and retireMeasureOverlap options will preserve the referent location information of existing events whenever possible.

Syntax:

[
  { "id" : <layerId1>,
      "allowMerge" : <true | false>,
      "retireMeasureOverlap" : <true | false>,
      "retireByEventId" : <true | false>,
      "adds" : [ <record1>, <record2>, ... ],
      "updates" : [ <record1>, <record2>, ... ],
      "deletes" : [ <record1>, <record2>, ... ]
  },
  { "id" : <layerId2>,
      "allowMerge" : <true | false>,
      "retireMeasureOverlap" : <true | false>,
      "retireByEventId" : <true | false>,
      "adds" : [ <record1>, <record2>, ... ],
      "updates" : [ <record1>, <record2>, ... ],
      "deletes" : [ <record1>, <record2>, ... ]
  },
  ...
]

An add event record has the following format. Each record must contain at least a Route ID attribute value. In addition, point events must contain a Measure value, and linear events must contain From and To Measure values. Attribute names are case sensitive.

{
  "attributes" : {
    "<field1>" : <value1>,
    "<field2>" : <value2>,
    ...
  }
}

An update event record has the following format. Each record must contain at least the eventId property or the where property to define the set of records to update. If the eventId property is specified, then the optional fromDate property may be specified to uniquely identify a single record to update out of all the temporal records for a given eventId. The attributes object should contain only those attribute values that are to be updated. Attribute names are case sensitive.

{
  "eventId" : <eventId>,  // string or number value
  "fromDate" : <fromDate>,  // date value
  "where" : "<whereClause>",
  "attributes" : {
    "<field1>" : <value1>,
    "<field2>" : <value2>,
    ...
  }
}

A delete event record has the following format. Each record must contain at least the eventId property or the where property to define the set of records to delete. If the eventId property is specified, then the optional fromDate property may be specified to uniquely identify a single record to delete out of all the temporal records for a given eventId.

{
  "eventId" : <eventId>,  // string or number value
  "fromDate" : <fromDate>,  // date value
  "where" : "<whereClause>"
}
gdbVersion

Description: The geodatabase version to which edits are applied. This parameter applies only if the isDataVersioned property of the edited layers is true. If this parameter is not specified, edits are made to the published map’s version.

Example Usage

Example 1

URL for adding new events to a point event layer.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":1,"adds":[{"attributes":{"route_id":"I90","event_id":"ABC123","meas":48.5}}]}]

Example 2

URL for adding new events to a linear event layer.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"adds":[{"attributes":{"RouteID":"US101","EventID":"ABC123","FromMeasure":20,"ToMeasure":25.75}}]}]

Example 3

URL for adding new events with a temporal view date range.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":3,"adds":[{"attributes":{"ROUTEID":"SR85","EVENTID":"ABC123","MEAS":35,"FROM_DATE":1230768000000,"TO_DATE":1262304000000}}]}]

Example 4

URL for adding new events with measure merging.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"allowMerge":true,"adds":[{"attributes":{"RouteID":"US101","EventID":"ABC123","Pavement":"concrete","FromMeasure":20,"ToMeasure":25.75}}]}]

Example 5

URL for adding new events with measure overlap retirement.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"retireMeasureOverlap":true,"adds":[{"attributes":{"RouteID":"US101","EventID":"ABC123","FromMeasure":20,"ToMeasure":25.75}}]}]

Example 6

URL for adding new events with referent locations.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"allowMerge":true,"retireMeasureOverlap":true,"adds":[{"attributes":{"RouteID":"US101","EventID":"ABC123","SpeedLimit":65,"FromMeasure":20,"ToMeasure":25.75,"FromRefMethod":12,"FromRefLocation":"{E9A2157D-DFD5-4696-943F-B35DD77C0BBE}","FromRefOffset":"125","ToRefMethod":20,"ToRefLocation":"{C061ECEC-C0BA-462D-BB73-DA175EAEFBD2}","ToRefOffset":"-50.3"}}]}]

Example 7

URL for updating events by WHERE clause.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"updates":[{"where":"Pavement = 'asphalt' and LaneCount = 2","attributes":{"LastPaved":1262304000000}}]}]

Example 8

URL for updating events by event ID.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"updates":[{"eventId":"ABC123","attributes":{"FromMeasure":42.5,"ToDate":null}}]}]

Example 9

URL for deleting events by WHERE clause.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":2,"deletes":[{"where":"RouteType = 'IN' and LaneCount < 3"}]}]

Example 10

URL for deleting events by event ID.

http://sampleserver/arcgis/rest/services/MyLRS/MapServer/exts/LRServer/applyEdits?f=json&edits=[{"id":4,"deletes":[{"eventId":500},{"eventId":501}]},{"id":1,"deletes":[{"eventId":"ABC123"}]}]

JSON Response Syntax

Example of when it's successful.

{
  "success" : true
}

JSON Response Syntax

Example of when an error occurs.

{
  "error" : {
    "code" : <errorCode>,
    "message" : "<errorMessage>",
    "details" : [ "<detail>", ... ]
  }
}