Home/Support/Support Forum/HTTP GET to iDigi data service did not get response correctly
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

HTTP GET to iDigi data service did not get response correctly

0 votes

I tried to fetch the data from my iDigi data service. Under ~/test there are two files: text.txt and TestData_20Jan2013_11_14_47.xml.

I was able to fetch the data using a web browser. But when I tried to do so using Python, it did not work.

Below is the python scripts that I used to do this job. But I did not get the files properly. Instead I got the following reposes. I got return code 200. But the returnmsg and getfile() did not seem correct. Did I do something wrong or miss something? Thanks.

Python Scripts Below

auth = base64.encodestring("%s:%s"%(USERNAME,PASSWORD))[:-1]
host = 'developer.idigi.com'
webservice = httplib.HTTP(host,80)
webservice.putrequest('GET', '/ws/data/~/test')
webservice.putheader("Authorization", "Basic %s"%auth)
webservice.putheader("Content-type", "text/xml; charset=\"UTF-8\"")
# get the reply to the request
returncode, returnmsg, headers = webservice.getreply()
# if successful, print out the contents of the XML file
if returncode == 200:
xml = webservice.getfile()
#print xml.read()
print returncode
print "\n"
print returnmsg
print "\n"
print headers

returncode, returnmsg, headers



content-length: 492
set-cookie: JSESSIONID=A262CCA2B41BCA653F92BF68D1F82029; Path=/ws; Secure
set-cookie: BIGipServerPOOL-; path=/
expires: -1
server: Apache-Coyote/1.1
last-modified: Mon, 21 Jan 2013 16:50:48 GMT
pragma: no-cache
cache-control: no-store
date: Thu, 24 Jan 2013 14:27:20 GMT
cachecontrol: no-cache
content-type: application/xml

Status: 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 10189
asked Jan 24, 2013 in Device Manager by lihui742 New to the Community (0 points)

Please log in or register to answer this question.

2 Answers

0 votes

Is there a reason you have this line commented out?
#print xml.read()

I tried running your code and when I uncommented that I got the actual contents of the file.

answered Jan 24, 2013 by cpopp Seasoned Professional (151 points)
0 votes
I got it work. I put print xml.read() back to codes.

Actually I updated the iDigi URL to my.idigi.com. I was told that if I keep using developer.idigi.com, it can be redirected now. But it will not work at one point in the future.

Thank you, Chris.

answered Jan 28, 2013 by hli_skyclimber New to the Community (1 point)