Update Features by Primary Key

Description

Updates features in a table by passing in a feature collection with an optional commitInterval. Each feature in the collection must have an ID (primary key) which is used to match the input feature with the feature in the table. The body of the request contains the JSON representation of the feature collection, although certain elements are not necessary to specify. The response contains the number of features that were successfully updated.

The body JSON representation is in GeoJSON format. For more information on GeoJSON, see geojson.org/geojson-spec.html.

Note: You must have View permissions on the named table as well as Create/Modify/Delete permissions on the named table's associated dataset to perform insert, update, and delete operations on writable tables. See Access Control for Datasets in the Administration section for more information.
Note: Update is supported on PostGIS, Oracle, SQL Server, SAP HANA, GeoPackage, and generic JDBC tables. It also supported on MapInfo native TAB and extended native TAB (NativeX) files on Windows operating systems only (the commitInterval is ignored). The table must have a primary key or it will be considered a read-only table. Named tables with composite primary keys are not writable.

ACL Authorization Flow

To update features in a named table by passing in a feature collection with an optional commit interval, the user (or any roles they belong to) will need Execute and Modify permissions on the named table in the following manner:

  • “EXECUTE” for entity type “Location Intelligence.Named Resources”
  • ”MODIFY” for entity type “Location Intelligence.Dataset.DML” respectively

HTTP POST URL Format

The following format is used for HTTP POST requests:


HTTP POST:  /tables/tablename/features.rep?
POST Data: action=update;[commitInterval=c]
POST BODY: Content-Type:application/json {table update}
			

The table update is a POST json body (Content-Type: application/json) for the table update containing one or multiple features to be updated.

Parameters

For information on the parameter types listed below, see Request URL Data Types.

Parameter Type Required Description
tablename String yes The name of the table for which you are updating features. The table is specified by a fully qualified name for the named table based on the location of the named table in the Repository. The name of the named table is defined between the /tables portion of the URL and the /features.rep portion of the URL. For example, to update features in a named table located at /Samples/NamedTables/WorldTable in the Repository, the following URL would be used:
.../FeatureService/tables/Samples/​NamedTables
/WorldTable/features.json;... 
rep String yes The representation to be returned. Supported representation is json.
action=update String yes The action to update the features in the table.
commitInterval=c Integer no The number of updates that will be processed in a transaction. For instance, if you are updating 50 features in a table and the commitInterval is set to 20, then you will have three transactions (20, 20, 10). The default value is 50. CommitInterval is ignored for native TAB and NativeX files.

Returns

Returns the primary key of each updated feature in the table.

Example

Updates two features in MyTable consisting of points in the geometry column, values of 456 and 123 to Column1, and values of "four five six" and "one two three" to Column2.


http://www.pbbi.com/rest/Spatial/FeatureService/tables/MyTable/features.json
?action=update&commitInterval=2

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "1",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -73,
                    41
                ]
            },
            "properties": {
                "Column1": 456,
                "Column2": "four five six"
            }
        },
        {
            "type": "Feature",
            "id": "2",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -72,
                    42
                ]
            },
            "properties": {
                "Column1": 123,
                "Column2": "one two three"
            }
        }
    ]
}