5.1.5. Editing

5.1.5.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
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.

5.1.5.2. 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)

5.1.5.3. 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
  • file_bucket (jsonobj) – file bucket JSON object
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.

5.1.5.4. 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
  • 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/

5.1.5.5. Change feature

To change feature in vector layer 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 Object:
 
  • geom (string) – geometry in WKT format (geometry type ans spatial reference must be corespondent to layer geometry type and spatial reference)
  • id (int) – feture 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 geom 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 ans 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) – feture identifier
Status Codes:

Request accept array of JSON objects. If feature identifier is not present in vector layer - feature will be created, else - changed.

5.1.5.6. 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: */*

5.1.5.7. 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: */*