Hello,
I am struggling to read trips report using python. I am always getting empty array as trips output. From web app I am able to see reports correctly.
Could you please give direction ?
My Python code :
cookie = login()
params = { 'deviceId' : str(445034462486), 'from' : "2018-06-28T00:00:00.000Z", 'to' : "2018-06-28T15:40:00.000Z" }
request = urllib2.Request(baseUrl + '/api/reports/trips?' + urllib.urlencode(params))
request.add_header('Content-Type', 'application/json')
request.add_header('Accept', 'application/json')
request.add_header('Cookie', cookie)
request.get_method = lambda: 'GET'
response = urllib2.urlopen(request)
print response.getcode()
html = response.info()
print response.readlines()
response.close()
print "Get all data: ", html
And I am getting following output:
200
['[]']
Get all data: Date: Thu, 28 Jun 2018 11:15:51 GMT
Content-Type: application/json
Access-Control-Allow-Headers: origin, content-type, accept, authorization
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Content-Length: 2
Server: Jetty(9.2.24.v20180105)
Connection: Keep-Alive
Age: 0
X-RBT-Optimized-By: ap-in-1156-chennai-sh01 (RiOS 9.1.4a) IK
If you send same request as the web app, you should get the same result. Compare requests.
Hello,
I am struggling to read trips report using python. I am always getting empty array as trips output. From web app I am able to see reports correctly.
Could you please give direction ?
My Python code :
cookie = login() params = { 'deviceId' : str(445034462486), 'from' : "2018-06-28T00:00:00.000Z", 'to' : "2018-06-28T15:40:00.000Z" } request = urllib2.Request(baseUrl + '/api/reports/trips?' + urllib.urlencode(params)) request.add_header('Content-Type', 'application/json') request.add_header('Accept', 'application/json') request.add_header('Cookie', cookie) request.get_method = lambda: 'GET' response = urllib2.urlopen(request) print response.getcode() html = response.info() print response.readlines() response.close() print "Get all data: ", html
And I am getting following output: