Insert a Feature into a Table

Description

Inserts one or more records into a table. The body of the request contains the JSON representation of the feature collection, although certain elements are not necessary to specify. Each of these features contains zero or more column values. If a column is not specified, a null value will be inserted. A column value must be specified if it is part of a primary key whose value is not handled by the database (i.e. via an auto-increment constraint or sequence). To determine the primary key, examine the key definition in the describeTable response. The response contains the primary keys of features that were successfully inserted.

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: Insert is supported on PostGreSQL/PostGIS, Oracle, SQL Server, SAP HANA, GeoPackage, and generic JDBC tables. 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.

HTTP POST URL Format

The following format is used for HTTP POST requests:


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

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

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 to insert the 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 insert a feature 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=insert String yes The action to insert the features into the table.
commitInterval=c Integer no The number of inserts that will be processed in a transaction. For instance, if you are inserting 50 features into a table and the commitInterval is set to 20, then you will have three transactions (20, 20, 10). The default is 50.

Returns

Returns the primary key of each added feature to the table.

Example

Adds two new feature to the 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=insert&commitInterval=1
{
    "type": "FeatureCollection",
    "features": [
    {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [-73, 41]
        },
        "properties": {
            "Column1": 456,
			"Column2": "four five six"
        }
    },
    {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [-72, 42]
        },
        "properties": {
            "Column1": 123,
			"Column2": "one two three"
        }
    }]
}