Home/Support/Support Forum/Getting a recently modified file list from the Device Cloud
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Getting a recently modified file list from the Device Cloud

0 votes
This doesnt work on the WR21 or my native python environment on my PC using this exact file with my login credentials. This is using code from the Etherios API Explorer and Documentation. I am able to get directory listings and actual files just fine. The same call in the browser also works as expected, but not in the Python environment.
# The following lines require manual changes username = ''# enter your username password = '' # enter your password # Nothing below this line should need to be changed # ------------------------------------------------- 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("login.etherios.com",80) # to what URL to send the request with a given HTTP method webservice.putrequest("GET", "/ws/FileData?condition=fdType='file' and fdLastModifiedDate>'2013-12-06T10:50:00.000Z'") #505 Version not supported error # "http://login.etherios.com/ws/FileData?condition=fdType='file' and fdLastModifiedDate>'2013-12-06T10:50:00.000Z'" #works in browser... # 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

http://ftp1.digi.com/support/documentation/html/90002008/90002008_N/index.htm#Programming Topics/Resources.htm#FileData%3FTocPath%3DDevice%20Cloud%20Programming%20Guide%7CResources%7C_____6
asked Feb 7, 2014 in Device Cloud by radix07 New to the Community (26 points)
retagged Feb 12, 2014 by radix07

Please log in or register to answer this question.

1 Answer

+1 vote

The problem is likely that the spaces in the URL are not appropriately URL encoded. If you change the spaces to %20 it should work:

webservice.putrequest("GET", "/ws/FileData?condition=fdType='file'%20and%20fdLastModifiedDate>'2013-12-06T10:50:00.000Z'") #505 Version not supported error

Your browser automatically URL encodes the spaces which is why it works there and not from the script.
answered Feb 19, 2014 by cpopp Seasoned Professional (150 points)
Contact a Digi expert and get started today! Contact Us