Ad Widget

Collapse

Trouble with Invalid JSON Parse Error

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Trouble with Invalid JSON Parse Error

    Hi All,

    I am having some difficulty getting the Zabbix 2.21 API to work using a Python wrapper.

    I'm passing the object parameters per the Zabbix API documentation, and nothing looks amiss in the pyzabbix library or my test script.

    I am authenticating and connecting to the Zabbix server without issue.
    No matter what field I try to get (I am using host.get(output="extend") as a test) I am getting the error

    Code:
    pyzabbix.ZabbixAPIException: ("Error 32700: Parse Error, Invalid JSON. An error occurred on the server while parsing the JSON text. while sending {'params': {'output': 'extend'}, 'jsonrpc': '2.0', 'method': 'host.get', 'id': 0}", -32700)
    Any ideas? I came across a couple of posts from 1-2 years ago but those didn't offer any solutions.

    I should note I tried a direct curl test and that produces the same error.

    Thanks in advance,
    D
    Last edited by ds_scalar; 19-09-2014, 18:12. Reason: Clarification and added Zabbix version

    #2
    Update:

    I am working with our Zabbix admin on this issue and we have narrowed it to likely being some kind of permissions issue but the issue is hard to pinpoint. There are two main anomalies.

    Problem #1:
    Oddly, curl tests placed in a shell script as well as the Python API are still failinf with the 32700 error, however we have worked around this by putting the JSON content into a text file jsontestdata and calling it from curl, like so:
    Code:
    curl -k -H "Content-Type: application/json" --data @jsontestdata https://zabbixhost/api_jsonrpc.php
    Doing so with my credentials (which are in the admin group) and calling the user.login() method returns:
    Code:
    {"jsonrpc":"2.0","result":"387ffe6b51ec09cb56a304338428a311","id":1}
    Problem #2:
    Any method other than user.login() fails and spits back:
    Code:
    {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Not authorized"},"id":1}
    If I am logging in and a member of the admin group, why do other API method calls fail?

    Comment


      #3
      I'm writing my code in powerhsell and I had the same validation error.
      I was using Invoke-WebRequest, then I changed to Invoke-RestMethod and now api "understand" my json.
      Curl never worked for me.
      (I'm in Zabbix 4.2)

      Comment

      Announcement

      Collapse
      No announcement yet.
      Working...
      X