Mango REST API and Watch Lists
-
Hi all,
I can successfully create Watch Lists through the Mango REST API using Node.js and Javascript, but how can I assign data points to them?
I have tried retrieving an existing watchlist through GET /v1/watch-lists, but it doesn't have any information about the data points in it. I can get all the data points throught GET /v1/watch-lists/{xid}/data-points, but I still don't get how to create a watchlist and associate data points to it.
Any ideas? Is it a two-step process (creating the watchlist first with POST and updating it later with PUT?)?
Thanks in advance.
-
It depends on the type of Watchlist. There are 3 types, static, point query and point hierarchy.
Static will have an array of points (
points
) set on it (Not actually the full points, you can get those from the URL you posted), point query has aquery
property which is just the RQL query for the data points end-point, and the point hierarchy has an array of folder ids (folderIds
) from which it gets its points.So no, its not a two step process. I'd suggest opening the Chrome debugger and watching the requests to
/rest/v1/watch-lists
when saving a watch list. -
Hi silvia,
I'm surprised you didn't see the information about how the points are selected. Here are three models for the three watchlist types, static, query, and hierarchy,
Static:
{ "xid": "WL_Static", "name": "Test", "modelType": "WATCH_LIST_SUMMARY", "validationMessages": [], "points": [ { "xid": "DP_NT__2_22_1st_Flr_Auditorium_N_TID", "name": "tid", "deviceName": "2-22 1st Flr Auditorium N", "pointFolderId": 31, "readPermission": "", "setPermission": "" }, { "xid": "DP_NT__2_22_1st_Flr_Auditorium_N_FanStatus", "name": "fan_status", "deviceName": "2-22 1st Flr Auditorium N", "pointFolderId": 31, "readPermission": "", "setPermission": "" } ], "type": "static", "query": null, "params": null, "readPermission": null, "username": "admin", "editPermission": null, "folderIds": null, "data": null, "id": 1 }
Notice the data point summaries. But, you can import these with only an "xid" in the point object and it'll import fine.
Query:
{ "xid": "WL_Query", "name": "TempForecast", "modelType": "WATCH_LIST_SUMMARY", "validationMessages": [], "points": [], "type": "query", "query": "like(name,Temperature%20Forecast)&sort(deviceName,name)&limit(200)", "params": null, "readPermission": "user", "username": "admin", "editPermission": "edit-watchlists", "folderIds": null, "data": { "paramValues": {} }, "id": 129 }
Notice the "query" member.
Hierarchy:
{ "xid": "WL_Hierarchy", "name": "PH", "modelType": "WATCH_LIST_SUMMARY", "validationMessages": [], "points": [], "type": "hierarchy", "query": null, "params": null, "readPermission": "user", "username": "admin", "editPermission": "edit-watchlists", "folderIds": [ 20, 45 ], "data": null, "id": 161 }
Notice the "folderIds" member
-
Thanks guys, I'll try it out today or next week and see how it goes! :)
-
It goes perfectly, thanks again!