HTTP GET to iDigi data service did not get response correctly

Hi,

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\"")
    webservice.endheaders()
    # 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 "

"
print returnmsg
print "
"
print headers


-------------returncode, returnmsg, headers -------------------------------

200

OK

content-length: 492
set-cookie: JSESSIONID=A262CCA2B41BCA653F92BF68D1F82029; Path=/ws; Secure
set-cookie: BIGipServerPOOL-50.56.41.152-PRD-MYIDIGI-CC-80=153794058.20480.0000; 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

Hi,

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.

Thanks,
Chris

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.

Hui