In the previous sample, we've created, edited, and deleted a unit. Units (like users, retranslators, unit groups etc.) are independent items. However, there are sub-items in Wialon which exist as a part of an independent item. For instance, a resource can have such sub-items like geofences, notifications, jobs, geozones, drivers etc.
Standard operations with sub-items a bit differ from those with independent items. In this example, we'll examine creating, editing and deleting a geozone as a sub-item of a resource.
Let's create a geozone using the request svc=resource/update_zone:
https://hst-api.wialon.host/wialon/ajax.html?svc=resource/update_zone& params={ {"n":"Madrid", "d":"Autopista M-50, San Fernando de Henares 28830, Madrid, Spain", "t":3, "w":10000, "f":112, "c":2568583984, "tc":16733440, "ts":12, "min":0, "max":18, "libId":"", "path":"", "p":[{"x":-3.715235,"y":40.415273,"r":10000}], "itemId":37, "id":0, "callMode":"create" }&sid=<your_sid>
Response:
[8,{"n":"Madrid","d":"Autopista M-50, San Fernando de Henares 28830, Madrid, Spain","id":8,"f":112,"t":3,"w":10000,"e":19652,"c":2568583984,"i":4294967295,"libId":0,"path":"","b":{"min_x":-3.83305691988,"min_y":40.3252262094,"max_x":-3.59741308012,"max_y":40.5053197906,"cen_x":-3.715235,"cen_y":40.415273},"ct":1559737413,"mt":1559737413}]
To check that the geozone has been created and to get detailed information about it, make the request:
https://hst-api.wialon.host/wialon/ajax.html?svc=resource/get_zone_data& params={ "itemId":37, "col":[8] }&sid=<your_sid>
Response:
[{"id":8,"n":"Madrid","d":"Autopista M-50, San Fernando de Henares 28830, Madrid, Spain","rid":37,"t":3,"w":10000,"f":112,"c":2568583984,"tc":16733440,"ts":12,"min":0,"max":18,"i":4294967295,"libId":0,"path":"","ar":314159265.359,"pr":62831.8530718,"b":{"min_x":-3.83305691988,"min_y":40.3252262094,"max_x":-3.59741308012,"max_y":40.5053197906,"cen_x":-3.715235,"cen_y":40.415273},"p":[{"x":-3.715235,"y":40.415273,"r":10000}],"ct":1559737413,"mt":1559737413}]
Now let's change the name and radius of the new geozone:
https://hst-api.wialon.host/wialon/ajax.html?svc=resource/update_zone& params={ "n":"Gurtam", "d":"Autopista M-50, San Fernando de Henares 28830, Madrid, Spain", "t":3, "w":5000, "f":112, "c":2568583984, "tc":16733440, "ts":12, "min":0, "max":18, "libId":"", "path":"", "p":[{"x":-3.715235,"y":40.415273,"r":10000}], "itemId":37, "id":8, "callMode":"update" }&sid=<your_sid>
Response:
[1, { [8,{"n":"Gurtam","d":"Autopista M-50, San Fernando de Henares 28830, Madrid, Spain","id":8,"f":112,"t":3,"w":5000,"e":19652,"c":2568583984,"i":4294967295,"libId":0,"path":"","b":{"min_x":-3.83305691988,"min_y":40.3252262094,"max_x":-3.59741308012,"max_y":40.5053197906,"cen_x":-3.715235,"cen_y":40.415273},"ct":1559737413,"mt":1559737413}] }]
To delete a geozone, use the request resource/update_geozone:
https://hst-api.wialon.host/wialon/ajax.html?svc=resource/update_geozone& params={ "itemId":37, "id":8, "callMode":"delete" }&sid=<your_sid>
Response:
[1, null]