-
Incident report
-
Resolution: Fixed
-
Trivial
-
None
-
None
-
None
-
Python file (py version = Python 3.9.2)
Thanks to the API, I have a python file to execute to delete a host on Zabbix.
My file looks like this:
import json import requests # Spécifiez l'URL de l'API Zabbix et le jeton d'accès API url = 'http://localhost/zabbix/api_jsonrpc.php' headers = {'Content-Type': 'application/json-rpc'} auth_token = mytoken # Créez une requête JSON-RPC pour la commande host.createpayload = { "jsonrpc":"2.0", "method":"host.delete", "params":[ { "hostid":10454 }, ], "auth":auth_token, "id":2 } # Envoyez la requête à l'API Zabbixresponse = requests.post(url, headers=headers, data=json.dumps(payload)) # Affichez la réponse de l'API Zabbixprint(response.json())
I call my file using the command: python3 myfile.py
I get this error:
{'jsonrpc': '2.0', 'error': {'code': -32500, 'message': 'Application error.', 'data': "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND h.status IN (0,1)' at line 1"}, 'id': 2}
By searching I saw that it could be the id I give that caused the problem, but he's the good one and I tried to give it as an int or as a string so this is maybe not from here. If it is not I have no idea<here it can come from.