Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection error #63

Open
Greg-13 opened this issue Dec 15, 2016 · 4 comments
Open

Connection error #63

Greg-13 opened this issue Dec 15, 2016 · 4 comments

Comments

@Greg-13
Copy link

Greg-13 commented Dec 15, 2016

Hi,
I am sorry to bother you with that, but since we upgraded our zabbix (zabbix 3 to 3.2), we got the following error :

Error connection Zabbix :("Error -32700: Parse error, Invalid JSON. An error occurred on the server while parsing the JSON text. while sending {'params': {'password': 'MyPASS', 'user': 'MyUserZabbixAPI'}, 'jsonrpc': '2.0', 'method': 'user.login', 'id': '1'}", -32700)

Function :

def pyzabbix(alarme,valeur):
try:
# Create ZabbixAPI class instance
zapi = ZabbixAPI(url='https://My-zabbix.server/', user='MyUserZabbixAPI', password='MyPASS')
zapi.api_version()
print zapi
# Send metrics to zabbix trapper
packet = [
ZabbixMetric('MyHost', alarme, valeur)
]
result = ZabbixSender(use_config=True).send(packet)
print result
except Exception as e:
print "Error connection Zabbix :" + str(e)

Do you have an idea ?

Thank you ! 👍

@Greg-13
Copy link
Author

Greg-13 commented Dec 15, 2016

I tried with Curl

data :

{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "MyUserZabbixAPI",
"password": "MyPASS"
},
"id": 1
}

Results
# curl -k -H "Content-Type: application/json" --data @data https://My-zabbix-server/api_jsonrpc.php {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}

@mcblum
Copy link

mcblum commented Jan 8, 2018

@Greg-13 did you ever figure this out? I'm stuck at the same place.

@roberdaniel
Copy link

Hi, we are having the same issue with Zabbix 4.2 :(

@roberdaniel
Copy link

roberdaniel commented May 23, 2019

I resolved it using Invoke-RestMethod instead of Invoke-WebRequest, and now api "understand" my json. (powershell code)
Curl never worked for me. is equivalent to to Invoke-WebRequest.
(I'm in Zabbix 4.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants