Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

REST V1/V2 Update Point Values help


  • I am struggling with updating a point value using python. I get a 200 status code and everything looks kosher but the value does not update... as you can see i write to the value get a 200 response then check the value using the v1 rest address and its still the old value.. i was able to get it to change but this may have been via the swagger testing suite. Below i try to change the value to 12.5 - get a 200 status code then read it back and see its still 55.

    map@SE2526:/$ python
    Python 2.7.15+ (default, Nov 27 2018, 23:36:35)
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import requests
    >>> import json
    >>> bearertoken = 'Bearer <insert your token here>'
    >>> headers = {'Accept':'application/json','Content-Type': 'application/json','Authorization': bearertoken }
    >>> curtailxid = 'DP_05bf6e60-8a86-42a7-9284-0e74cf56f902'
    >>> xid = curtailxid
    >>> dd =  {"annotation": "Help!","dataType": "NUMERIC","timestamp": 0,"value": 12.5,"xid": "DP_05bf6e60-8a86-42a7-9284-0e74cf56f90"}
    >>> putDPurl = 'http://192.168.10.130:8080/rest/v1/point-values/' + xid + '?unitConversion=false'
    >>> putDPurl2 = 'http://192.168.10.130:8080/rest/v2/point-values/DP_05bf6e60-8a86-42a7-9284-0e74cf56f902/attributes'
    >>> r = requests.put(putDPurl2,headers = headers, data=json.dumps(dd))
    >>>
    >>> r.status_code
    200
    >>> r.text
    u'{"annotation":"Help!","xid":"DP_05bf6e60-8a86-42a7-9284-0e74cf56f90","dataType":"NUMERIC","value":12.5,"timestamp":0}'
    >>> getDPurl = 'http://192.168.10.130:8080/rest/v1/point-values/' + xid + '/latest?useRendered=false&unitConversion=false&limit=1&useCache=true'
    >>> r = requests.get(getDPurl, timeout=5, headers=headers);
    >>> r.status_code
    200
    >>> r.text
    u'[{"cached":true,"dataType":"NUMERIC","value":55.5,"timestamp":1591856389181,"annotation":null}]'
    >>>
    

  • well I think this works for anyone interested ->

    Python 2.7.15+ (default, Nov 27 2018, 23:36:35)
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    >>> import requests
    >>> import json
    >>> bearertoken = 'Bearer <your token here>'
    >>> headers = {'Accept':'application/json','Content-Type': 'application/json','Authorization': bearertoken }
    >>> curtailxid = 'DP_05bf6e60-8a86-42a7-9284-0e74cf56f902'
    >>> xid = curtailxid
    >>> currentprice = 5555
    >>> dd =  {"dataType": "NUMERIC","timestamp": 0,"value": currentprice,"xid": "DP_05bf6e60-8a86-42a7-9284-0e74cf56f90"}
    >>> putDPurl = 'http://192.168.10.130:8080/rest/v1/point-values/' + xid + '?unitConversion=false'
    >>> #putDPurl2 = 'http://192.168.10.130:8080/rest/v2/point-values/DP_05bf6e60-8a86-42a7-9284-0e74cf56f902/attributes'
    ... r = requests.put(putDPurl,headers = headers, data=json.dumps(dd))
    >>>
    >>> r.status_code
    201
    >>> r.text
    u'{"dataType":"NUMERIC","value":5555,"timestamp":1591858602770,"annotation":null}'
    >>>
    

  • Correct, you were using the wrong api url.