I'm trying to get started with the Zabbix API, but I always get HTTP 412 responses no matter what I try.
I'm using Python and Zabbix 2.0.3.
I've tried some other operations like host.create, but I always get the same 412 error.
In the Apache access logs, I see
Has anyone experienced this problem and know of a workaround?
Thanks,
I'm using Python and Zabbix 2.0.3.
Code:
import urllib2
import simplejson
a = { 'jsonrpc': '2.0', 'method': 'user.login', 'params': { 'user': 'Admin', 'password' : '*******'}, 'id' : 1}
b = simplejson.dumps(a)
c = urllib2.urlopen('http://MYSERVER/zabbix/api_jsonrpc.php', data=b)
Code:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib64/python2.6/urllib2.py", line 397, in open
response = meth(req, response)
File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.6/urllib2.py", line 435, in error
return self._call_chain(*args)
File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 412: Precondition Failed
In the Apache access logs, I see
Code:
MYSERVERIP - - [22/Jan/2013:14:47:55 -0600] "POST /zabbix/api_jsonrpc.php HTTP/1.1" 412 - "-" "Python-urllib/2.6"
Thanks,
Comment