14.1.9. Editing

14.1.9.1. Change resource

Execute following PUT request to change resource.

PUT /api/resource/(int: id)

Change resource request

Request Headers
Parameters
  • id – resource identifier

Request JSON Object
  • resource (jsonobj) – resource JSON object

  • display_name (string) – resource new name

  • keyname (string) – resource new key

  • id (int) – resource new parent identifier (resource will move to new parent)

  • description (string) – resource new description

  • permissions (jsonarr) – resource permissions array

Status Codes

Example request:

PUT /api/resource/8 HTTP/1.1
Host: ngw_url
Accept: */*

{"resource":
   {
       "display_name":"test3",
       "keyname":"qw4",
       "parent":{"id":7},
       "permissions":[],
       "description":"rrr5"
    }
}

Note

Payload of this request may be equal to create new resource request payload, but some fields can be omitted. Request must be authorized.

Move resource in terminal:

url='https://sandbox.nextgis.com'
login='administrator'
password='demodemo'

curl -d '{"resource":{"parent":{"id":373}}}' -u $login:$password -X PUT $url/api/resource/381

Change display name of resource

14.1.9.2. Change webmap

When changing layers in webmap, you should set in PUT query both ‘children’ and ‘item_type’ objects.

Example request:

layer1 = {
  "layer_adapter": "tile",
  "layer_enabled": None,
  "style_parent_id": 454,
  "draw_order_position": None,
  "layer_max_scale_denom": None,
  "payload": None,
  "item_type": "layer",
  "layer_min_scale_denom": None,
  "display_name": "gidro_ln",
  "layer_style_id": 478,
  "layer_transparency": None
}
layer2 = {
  "layer_adapter": "tile",
  "layer_enabled": True,
  "style_parent_id": 453,
  "draw_order_position": None,
  "layer_max_scale_denom": None,
  "payload": None,
  "item_type": "layer",
  "layer_min_scale_denom": None,
  "display_name": "qml/rast2_ln",
  "layer_style_id": 489,
  "layer_transparency": None
}

layers = (layer1,layer2)
payload = {'webmap':{'root_item':{'item_type':'root', 'children': layers  } }}

url=self.ngw_url+'/api/resource/'+str(webmap_id)
response = requests.put(url, json = payload, auth=self.ngw_creds)

14.1.9.3. Change metadata

This query create metadata fields, or updating it if they exists.

Example request:

PUT /api/resource/8 HTTP/1.1
Host: ngw_url
Accept: */*

{
   "resmeta":{
      "items":{
         "UPDATED_AT":"2018-11-07 14:00",
         "CHECKED_AT":"2018-11-07 12:00"
      }
   }
}

Same steps with curl:
curl --user "user:password" -H 'Accept: */*' -X PUT -d '{"resmeta": {"items":{"UPDATED_AT":"2018-11-07 14:00", "CHECKED_AT":"2018-11-07 12:00"}}}' http://<ngw url>/api/resource/(int:id)

14.1.9.4. Change file bucket resource

To change file bucket execute following PUT request:

PUT /api/resource/(int: id)

Change file bucket request.

Request Headers
Parameters
  • id – resource identifier

Request JSON Object
  • resource (jsonobj) – resource JSON object

  • cls (string) – type (must be file_bucket, for a list of supported types see Resource classes)

  • parent (jsonobj) – parent resource json object

  • id (int) – parent resource identifier

  • display_name (string) – name

  • keyname (string) – key (optional)

  • description (string) – description text, HTML supported (optional)

  • file_bucket (jsonobj) – file bucket JSON object

  • files (jsonarr) – array of files should present in bucket: present (which need to delete don’t include in array), also new files (upload response JSON object, files == upload_meta)

Status Codes

Example request:

PUT /api/resource/22 HTTP/1.1
Host: ngw_url
Accept: */*

 {
   "file_bucket": {
     "files": [
       {
         "mime_type": "application/x-dbf",
         "name": "grunt_area_2_multipolygon.dbf",
         "size": 36607
       },
       {
         "mime_type": "application/x-esri-shape",
         "name": "grunt_area_2_multipolygon.shp",
         "size": 65132
       },
       {
         "mime_type": "application/x-esri-shape",
         "name": "grunt_area_2_multipolygon.shx",
         "size": 1324
       },
       {
         "id": "fb439bfa-1a63-cccc-957d-ae57bb5eb67b",
         "mime_type": "application/octet-stream",
         "name": "grunt area description.txt",
         "size": 50
       }
     ]
   },
   "resource": {
     "cls": "file_bucket",
     "description": "some new text",
     "display_name": "new grunt_area",
     "keyname": null,
     "parent": {
       "id": 0
     }
   }
 }

In this example, file grunt area description.txt will added, files grunt_area_2_multipolygon.cpg, grunt_area_2_multipolygon.prj - deleted, and bucket name and description will changed.

14.1.9.5. Change lookup table resource

To change flookup table execute following PUT request:

PUT /api/resource/(int: id)

Change lookup table request.

Request Headers
Parameters
  • id – resource identifier

Request JSON Object
  • resource (jsonobj) – resource JSON object

  • cls (string) – type (must be lookup_table, for a list of supported types see Resource classes)

  • id (int) – parent resource identifier

  • display_name (string) – name

  • keyname (string) – key (optional)

  • description (string) – description text, HTML supported (optional)

  • resmeta (jsonobj) – metadata JSON object. Key - value JSON object struct.

  • lookup_table (jsonobj) – lookup table values JSON object. Key - value JSON object struct.

Status Codes

Example request:

PUT /api/resource/22 HTTP/1.1
Host: ngw_url
Accept: */*

{
  "lookup_table": {
     "items": {
         "car": "Машина",
         "plane": "Самолет"
     }
  }
}

Same steps with curl:

$ curl --user "user:password" -H 'Accept: */*' -X PUT -d '{"lookup_table":
{"items":{"car":"Машина", "plane":"Самолет"}}}'
http://<ngw url>/api/resource/

14.1.9.6. Change feature

To change feature in vector layer execute following request:

PUT /api/resource/(int: layer_id)/feature/(int: feature_id)?srs=(int: srs)

Change feature request

Parameters
  • layer_id – layer resource identifier

  • feature_id – feature identifier

Query Parameters
  • srs – EPSG code for input SRS (will be automatically reprojected to destination SRS)

Request Headers
Request JSON Object
  • geom (string) – geometry in WKT format (geometry type and spatial reference must be corespondent to layer geometry type and spatial reference)

  • id (int) – feature identifier

Request JSON Array of Objects
  • fields – attributes array in form of JSON field name - value object

Status Codes

Example request:

PUT /api/resource/3/feature/1 HTTP/1.1
Host: ngw_url
Accept: */*

{
  "extensions": {
    "attachment": null,
    "description": null
  },
  "fields": {
    "Age": 1,
    "DateTr": {
      "day": 7,
      "month": 2,
      "year": 2015
    },
    "Davnost": 4,
    "Foto": 26,
    "Nomerp": 1,
    "Nomers": 1,
    "Samka": 0,
    "Sex": 3,
    "Sizeb": 0.0,
    "Sizef": 0.0,
    "Sizes": 9.19999980926514,
    "Snowdepth": 31,
    "Wher": "\u043b\u044b\u0436\u043d\u044f",
    "id01": 0
  },
  "geom": "MULTIPOINT (15112317.9207317382097244 6059092.3103669174015522)",
  "id": 1
}

In request payload add only changed fields. Other fields will stay unchanged. Also geometry field may be skipped.

To change features in batch mode use patch request.

PATCH /api/resource/(int: layer_id)/feature

Change features request

Parameters
  • layer_id – layer resource identifier

Request Headers
Request JSON Array of Objects
  • geom (string) – geometry in WKT format (geometry type and spatial reference must be corespondent to layer geometry type and spatial reference)

  • fields (jsonarr) – attributes array in form of JSON field name - value object

  • id (int) – feature identifier

Status Codes

Request accepts array of JSON objects. If feature identifier is not present in PATCH body a feature will be created, else - changed.

Example request:

PATCH /api/resource/3/feature/ HTTP/1.1
Host: ngw_url
Accept: */*

[
  {"geom": "POINT(30.20 10.15)", "fields": {"externalObjectId": "i1"}},
  {"id": 24, "geom": "POINT(30.20 10.15)", "fields": {"externalObjectId": "i2"}},
  {"geom": "POINT(30.20 10.15)", "fields": {"externalObjectId": "i3"}}
]

Example response body:

[
  {"id": 25},
  {"id": 24},
  {"id": 26}
]

14.1.9.7. Change attachment

Only following information can be changed: * file name * description

To change attachment execute following request:

PUT /api/resource/(int: layer_id)/feature/(int: feature_id)/attachment/(int: attachment_id)

Change feature request

Parameters
  • layer_id – layer resource identifier

  • feature_id – feature identifier

  • attachment_id – attachment identifier

Request Headers
Request JSON Object
  • name – new name

  • description – new description

Response JSON Object
  • id – attachment identifier

Status Codes

Example request:

PUT /api/resource/3/feature/1/attachment/4 HTTP/1.1
Host: ngw_url
Accept: */*

{"name": "49.qml", "description": "qqq"}
curl --user "user:password" 'https://sandbox.nextgis.com/api/resource/9/feature/1/attachment/4' -X PUT -H 'content-type: application/json' -H 'accept: */*' --data-binary '{"name": "49.qml", "description": "qqq"}'

14.1.9.8. Delete feature

To delete feature from vector layer execute following request:

DELETE /api/resource/(int: layer_id)/feature/(int: feature_id)

Delete feature request

Request Headers
Parameters
  • layer_id – resource identifier

  • feature_id – feature identifier

Status Codes

Example request:

DELETE /api/resource/3/feature/1 HTTP/1.1
Host: ngw_url
Accept: */*

14.1.9.9. Delete features

To delete list of features execute following request:

DELETE /api/resource/(int: layer_id)/feature/

Delete features request

Request Headers
Parameters
  • layer_id – resource identifier

Request JSON Array of Objects
  • id (int) – feature identifier

Status Codes

Example request:

DELETE /api/resource/3/feature/ HTTP/1.1
Host: ngw_url
Accept: */*

[{"id": 25},{"id": 24},{"id": 26}]

14.1.9.10. Delete all features

To delete all feature in vector layer execute following request:

DELETE /api/resource/(int: layer_id)/feature/

Delete features request

Request Headers
Parameters
  • layer_id – resource identifier

Status Codes

Example request:

DELETE /api/resource/3/feature/ HTTP/1.1
Host: ngw_url
Accept: */*

14.1.9.11. Delete attachment

To delete attachment from a feature execute following request:

DELETE /api/resource/(int: layer_id)/feature/(int: feature_id)/attachment/(int: attachment_id)

Delete feature request

Request Headers
Parameters
  • layer_id – resource identifier

  • feature_id – feature identifier

  • attachment_id – attachment identifier

Status Codes

Example request:

DELETE /api/resource/3/feature/1/attachment/1 HTTP/1.1
Host: ngw_url
Accept: */*
curl --user "user:password" -H 'Accept: */*' -X DELETE 'https://sandbox.nextgis.com/api/resource/9/feature/1/attachment/1'

14.1.9.12. Delete all attachments

To delete all attachments of a feature execute following request:

PUT /api/resource/(int: layer_id)/feature/(int: feature_id)

Change feature request

Parameters
  • layer_id – layer resource identifier

  • feature_id – feature identifier

Request Headers
Request JSON Array of Objects
  • extensions – empty attachment array

Response JSON Object
  • id – feature identifier

Status Codes

Example request:

PUT /api/resource/3/feature/1 HTTP/1.1
Host: ngw_url
Accept: */*

{
   "extensions":
   {
      "attachment":[]
   }
}
curl 'https://sandbox.nextgis.com/api/resource/9/feature/1' --user "user:password" -H 'Accept: */*' -X PUT -H 'content-type: application/json' --data-binary '{"extensions":{"attachment":[]}}'