Resource

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, POIs, 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 POI as a sub-item of a resource.

:!: Attention! To launch this example at Wialon Kit, change https://hst-api.wialon.com for https://kit-api.wialon.com in all requests and use user name and password of your account to login to the system or name and password of demo user kitdemo kitdemo.

Creating POI

Let's create a POI using the request resource/update_poi:

https://hst-api.wialon.com/wialon/ajax.html?svc=resource/update_poi&
	params={
		"itemId":50936,
		"id":0,
		"callMode":"create",
		"n":"gurtam",
		"d":"poi",
		"y":53.91069937030936,
		"x":27.516643322771575,
		"r":100,
		"f":1,
		"c":16733440,
		"tc":0,
		"ts":20,
		"min":0,
		"max":18
	}&sid=<your_sid>

Response:

[2, {
    "id": 1,
    "n": "gurtam",
    "y": 53.9106993703,
    "x": 27.5166433228,
    "t": 0,
    "i": 6515,
    "e": 48223
}]

To check that the POI has been created and to get detailed information about it, make the request get_poi_data:

https://hst-api.wialon.com/wialon/ajax.html?svc=resource/get_poi_data&
	params={
		"itemId":50936,
		"col":[1]
	}&sid=<your_sid>

Response:

[{
    "id": 1,
    "n": "gurtam",
    "d": "poi",
    "y": 53.9106993703,
    "x": 27.5166433228,
    "r": 100,
    "f": 1,
    "c": 16733440,
    "tc": 0,
    "ts": 20,
    "min": 0,
    "max": 18,
    "t": 0,
    "i": 6515
}]

Editing POI

Now let's change the name and radius of the new POI:

https://hst-api.wialon.com/wialon/ajax.html?svc=resource/update_poi&
	params={
		"itemId":50936,
		"id":1,
		"callMode":"update",
		"n":"gurtam_office",	/* change from "gurtam" to "gurtam_office" */
		"d":"poi",
		"y":53.91069937030936,
		"x":27.516643322771575,
		"r":50,			/* change from 100 to 50 */
		"f":1,
		"c":16733440,
		"tc":0,
		"ts":20,
		"min":0,
		"max":18
	}&sid=<your_sid>

Response:

[1, {
    "id": 1,
    "n": "gurtam_office",
    "y": 53.9106993703,
    "x": 27.5166433228,
    "t": 0,
    "i": 6515,
    "e": 50676
}]

You can check how changes have been applied by making the request get_poi_data.

Deleting POI

To delete a POI, use the request update_poi:

https://hst-api.wialon.com/wialon/ajax.html?svc=resource/update_poi&
	params={
		"itemId":50936,
		"id":1,
		"callMode":"delete"
	}&sid=<your_sid>

Response:

[1, null]
Follow us on Facebook Gurtam Wialon Twitter Gurtam Wialon info@gurtam.com   |   Copyright © 2002-2024 Gurtam