Hi all,
I've been working on making API calls to an AXIS camera and have found that simpler calls seem to be working fine but more complex calls have been giving me strange responses.
For example, calls to move my camera have no issues. However, calls that involve sending body information are returning strange responses.
The current call I am working with is:
import httplib
import urllib2
import urllib
import json
url = "http://***/axis-cgi/streamprofile.cgi"
data = {
"apiVersion": "1.0",
"context": "my context",
"method": "list",
"params": {
"streamProfileName": []
}
}
method = "POST"
password = urllib2.HTTPPasswordMgrWithDefaultRealm()
password.add_password(None, url, "***", "***")
handler = urllib2.HTTPDigestAuthHandler(password)
opener = urllib2.build_opener(handler)
request = urllib2.Request(url, data=data)
# headers
request.add_header("Content-Type","application/json")
request.add_header("Accept","*/*")
request.add_header("Accept-Encoding","gzip, deflate, br, compress, identity, *")
request.add_header("Connection","keep-alive")
# overload the get method
request.get_method = lambda: method
connection = opener.open(request)
print connection.read()
The return from the camera with this call is:
Note: This return is only possible by the 'Accept-Encoding' header because without it you perpetually get JSON formatting errors.
This general call is absolutely possible as it works wonderfully in Postman but there seems to be a disconnect between what I'm attempting to do in Ignition and what I can do with Postman for example.
Has anyone ran into this particular problem before? If so, do you know how to fix it? (Or a different way to extract the information from the response in Ignition, any ideas, etc)
Thank you,
Cam