I’m new to iDigi and trying to do a few evaluation tasks. I have data channels from an X4 w/ Zigbee modules populating data streams that I can access through the iDigi web UI. I am trying to write/modify some basic Python scripts to pull the data from the iDigi servers. Although I can access certain high level data with the Python app, I am getting various errors trying to get channel data. I have tried to base the Python scripts on examples I have found on the Digi web site and latest Idigi Web Services Programming Guide. Input into my mistakes would be apprecaited. Here is the Python code I am using with various commands I have been trying (one at a time). Where applicable, I included the section where I got the syntax from the programming guide.
import httplib
import base64
create HTTP basic authentication string, this consists of
“username:password” base64 encoded
auth = base64.encodestring(“%s:%s” % (username, password))[:-1]
webservice = httplib.HTTP(“my.idigi.com”, 80)
to what URL to send the request with a given HTTP method
webservice.putrequest(“GET”, “/ws/DiaChannelDataHistoryFull?condition=dcdUpdateTime>‘2013-01-16T21:34:18.000Z’”)
webservice.putrequest(“GET”, “/ws/DiaChannelDataFull”)
webservice.putrequest(“GET”, “/ws/DeviceCore”) # lists all gateways registered with iDigi account
webservice.putrequest(“GET”, “/ws/XbeeCore”) # lists all XBee resources registered with iDigi account
webservice.putrequest(“GET”, “/ws/ResourcePath”) # lists of resources - error 403
returns 403, Forbidden, same error from browser
webservice.putrequest(“GET”, “/ws/dia/channel/00000000-00000000-00409DFF-FF4BDB8A/sensor0/light/”)
returns 400, Bad Request (from section 17.3)
webservice.putrequest(“GET”, “/ws/DataPoint/dia/Channel/00000000-00000000-00409DFF-FF4BDB8A/sensor0/light”)
webservice.putrequest(“GET”, “/ws/DataStream”) # works
returns 505, HTTP Version Not Supported, works from browser URL bar (from section 4.3)
webservice.putrequest(“GET”, “/ws/DiaChannelDataFull/?condition=devConnectwareId=‘00000000-00000000-00409DFF-FF4BDB8A’ and dcChannelName=‘humidity’”)
add the authorization string into the HTTP header
webservice.putheader(“Authorization”, “Basic %s”%auth)
webservice.putheader(“Content-type”, “text/xml; charset="UTF-8"”)
webservice.endheaders()
get the response
statuscode, statusmessage, header = webservice.getreply()
response_body = webservice.getfile().read()
print the output to standard out
print (statuscode, statusmessage)
print response_body