Adding/updating points via the REST API.
-
We're trying to use the API to add and update points, but it doesn't seem to work.
When I try using "put /v1/data-points/{xid}:Update an existing data point", I get a 406 response.
{
"Date": "Wed, 09 Dec 2015 07:23:42 GMT",
"Errors": "Validation error",
"Content-Type": "application/json; charset=UTF-8",
"Transfer-Encoding": "chunked",
"Server": "Jetty(9.2.12.v20150709)"
}When I try to use the bulk update, I get response 200, but there is no change to the actual points.
{
"Date": "Wed, 09 Dec 2015 07:31:39 GMT",
"Content-Type": "application/json; charset=UTF-8",
"Transfer-Encoding": "chunked",
"Server": "Jetty(9.2.12.v20150709)"
}Someone was able to make it work?
-
It looks like your JSON data isn't validating properly. The response from Mango will contain a list of validation messages that will tell you what is wrong. The messages are in JSON and are the body of the response.
To get started I would suggest performing a GET and then a PUT with exactly the same JSON as received in the GET.
-
That's exactly what I tried, and I still get 406 response. Here is the body I get:
{
"enabled": true,
"templateXid": "Binary_Default",
"loggingProperties": {
"tolerance": 0,
"discardExtremeValues": false,
"discardLowLimit": -1.7976931348623157e+308,
"discardHighLimit": 1.7976931348623157e+308,
"loggingType": "ON_CHANGE",
"intervalLoggingType": "INSTANT",
"intervalLoggingPeriod": {
"periods": 15,
"type": "MINUTES"
},
"overrideIntervalLoggingSamples": false,
"intervalLoggingSampleWindowSize": 0,
"cacheSize": 1
},
"textRenderer": {
"zeroLabel": "zero",
"zeroColour": "blue",
"oneLabel": "one",
"oneColour": "black",
"type": "textRendererBinary"
},
"chartRenderer": {
"limit": 10,
"type": "chartRendererTable"
},
"modelType": "DATA_POINT",
"validationMessages": [
{
"message": "Required value",
"level": "ERROR",
"property": "alternateBooleanChange.startValue"
}
],
"dataSourceId": 0,
"deviceName": "A",
"chartColour": "blue",
"plotType": "STEP",
"purgeOverride": false,
"purgePeriod": {
"periods": 1,
"type": "YEARS"
},
"pointLocator": {
"dataType": "BINARY",
"settable": false,
"changeType": "ALTERNATE_BOOLEAN",
"modelType": "PL.VIRTUAL",
"relinquishable": false
},
"readPermission": "superadmin",
"setPermission": "superadmin",
"dataSourceXid": "teat 2-DS",
"pointFolderId": 0,
"unit": "",
"useIntegralUnit": false,
"integralUnit": "s",
"useRenderedUnit": false,
"renderedUnit": "",
"dataSourceName": null,
"id": 18,
"xid": "DP_519610",
"name": "A"
}The only difference from the get is the dataSourceId and Name that became 0 and null respectively. Any advice?
-
It looks like you found a bug in the Virtual Data Source data point model. You can see from the validation messages:
"validationMessages": [ { "message": "Required value", "level": "ERROR", "property": "alternateBooleanChange.startValue" } ],
But there is no member in the point locator for this in the model. I've just checked the code and can see the problem. I'll put together a fix for this. In the meantime try another data source type instead of Virtual.
-
On further investigation it doesn't look like any data points can be updated this way yet. The REST api for saving data points and data sources isn't fully implemented yet as we are still using the legacy way of modifying them in the UI.
For starters the Event Detectors cannot be modified via the DataPointModel so you won't be able to fully update a data point and most likely will get a 500 response when Mango tries to save it.
-
We are currently using the REST api to modify data points using the text/csv content type. This is limited though as only some of the fields are available while the remainder are applied via the templateXid.
-
@terrypacker I was able to update/create points for a BACnet device using the JSON format. So it seems that it works, at least partially.
Thanks for your help.