-
@Jdiaz-co I'm a little confused by your phrasing. Maybe use some URLs as examples. But are you asking if there exists a REST v3 endpoint to PUT multiple point's values or if one exists for v1?
There are POST methods for v3. I can't say for v1 as I don't have the code checked out.
POST
rest/v3/point-values
using a JSON model as the body (this is not recommended and deprecated)POST
rest/v3/point-value-modification/import
using a JSON model as the body. (See swagger UI for this) -
Sorry for my English. I'm currently using apiV1, but I'm considering migrating everything to apiV3, which uses Mango v5.0.2. In apiV1, there is a "PUT" function called "/point-values" that allows you to send multiple Datapoints at once. However, I see that this "PUT" in apiV3 either doesn't exist or has changed.
-
@Jdiaz-co I just checked and there is still and endpoint available via PUT. If you configure a data point to be 'settable' in the Mango UI and then open Chrome Dev tools while on the Data Point Details page you can set the value and see the PUT request. I can't upload images to the forum due to some problem. But here is the general output from the developer tools view:
Request URL: https://localhost:8443/rest/latest/point-values/DP_0f3b0e5d-b9ca-4f2f-916b-f2ddcadbba8a?unitConversion=true Request Method: PUT Status Code: 201 Payload: { "value":50, "dataType":"NUMERIC", "annotation":"Set from web by user: admin" }
-
Indeed, that endpoint works correctly; however, I can only send a single Datapoint in the request. My question is whether there is any endpoint where I can send multiple at once, as was possible in apiV1. I see, since I have tried that same endpoint and haven't been able to achieve it.
-
@Jdiaz-co that endpoint only accepts a single point value (as you have discovered). Referring back to my first post I think you are looking for this new v3 endpoint:
POST rest/v3/point-value-modification/import
using a JSON model as the body. (See swagger UI for this)I don't think this is exposed in the UI so you will need to use Swagger. However the POST body will need to look like this:
[ { "xid": "MY_POINT_1_XID", "value": 1.0, "timestamp": "ISO Formatted Date String", "annotation": "can be null or any string" }, { .... ]
The idea being that you supply the
xid
for the point you want to set the value for. -
@terrypacker said in apiv3:
POST rest/v3/point-value-modification/import
I've tried the POST "rest/v3/point-value-modification/import" you mentioned from Swagger, and it doesn't work for me when trying to input multiple Datapoints at once. Is there any other way?
-
@Jdiaz-co
I think it is missing"dataType":"NUMERIC"|"ALPHANUMERIC"|"BINARY"
You'll need that for each value entry.
Pretty sure that's why it's throwing its toys...Fox
-
Hello, in Swagger it works, that is, it gives me a 200 status code, but in Mango the value doesn't change.
I'm using this JSON to test it.:
[
{
"xid": "MY_DP",
"dataType":"NUMERIC",
"timestamp": 184965161,
"value": 4
}, {
"xid": "MY_DP",
"dataType":"NUMERIC",
"timestamp": 184965161,
"value": 2
}
]The response is this, however, as I mentioned, the value doesn't change in Mango.
[
{
"xid": "DP_RV-BAR-1CA_bar_cmd",
"totalQueued": 1,
"totalSkipped": 0,
"result": {
"messages": [],
"valid": true,
"hasMessages": false
}
},
{
"xid": "DP_RV-BAR-1CA_status",
"totalQueued": 1,
"totalSkipped": 0,
"result": {
"messages": [],
"valid": true,
"hasMessages": false
}
}
]Thank you for assisting me.
-
@Jdiaz-co your timestamp needs to be an ISO formatted date-time string, not a unix timestamp!
Fox
-
@MattFox thanks for your help, ISO formatted It has worked correctly with the ISO timestamp format.