Ad Widget

Collapse

Item Type HTTP Agent not parsing Json Response

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mreinhart
    Junior Member
    • Apr 2019
    • 3

    #1

    Item Type HTTP Agent not parsing Json Response

    Hi,

    i have a C# Applicate that return a Json status. It looks like:

    Code:
    {
      "prtg": {
        "result": [
          {
            "channel": "DDS - ZDM - Konsistenzprüfung",
            "value": "3",
            "valuelookup": "prtg.RCLookup.DDS_ZDM_Check.BitField"
          },
          {
            "channel": "ZDM DB Verbindungsversuche",
            "value": "0",
            "valuelookup": "prtg.RCLookup.Default.DB.Connect.Retry"
          }
        ]
      }
    }
    Then i have a zabbix item witch type is http agent.
    The request works fine. But i get the error:

    Code:
    Preprocessing failed for: HTTP/1.1 200 Ok..Content-Length: 361..Content-Type: application/json..Server: Grapevine/4.1.1.0 M...
    1. Failed: cannot extract value from json by path ".prtg.result[0].value": cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: 'HTTP/1.1 200 Ok
    Content-Length: 361
    Content-Type: application/json
    Server: Grapevine/4.1.1.0 Microsoft-HTTPAPI/2.0
    Date: Fri, 12 Apr 2019 14:19:12
    What is wrong?

    The JsonPath is: .prtg.result[0].value

    Can help me everybody?
  • mreinhart
    Junior Member
    • Apr 2019
    • 3

    #2
    Is there nobody who can help me.

    Comment

    • vso
      Zabbix developer
      • Aug 2016
      • 190

      #3
      did you select body only in frontend ?

      Comment

      • mreinhart
        Junior Member
        • Apr 2019
        • 3

        #4
        Ok. That's was the trick. But i don't understand why. I select "Retrieve mode" to Body and it works.
        Thanks!

        Comment

        • brunohl
          Senior Member
          Zabbix Certified Specialist
          • Mar 2019
          • 215

          #5
          It was because you were trying to parse all the HTTP response, not just the body.
          The HTTP response is like:

          Code:
          HTTP/1.1 200
          Date: Mon, 27 Jul 2009 12:28:53 GMT
          
          {
            "prtg": {
              "result": [
                {
                  "channel": "DDS - ZDM - Konsistenzprüfung",
                  "value": "3",
                  "valuelookup": "prtg.RCLookup.DDS_ZDM_Check.BitField"
                },
                {
                  "channel": "ZDM DB Verbindungsversuche",
                  "value": "0",
                  "valuelookup": "prtg.RCLookup.Default.DB.Connect.Retry"
                }
              ]
            }
          }
          You were trying to run JSON on all of this.

          Comment


          • mreinhart
            mreinhart commented
            Editing a comment
            Oh. OK. thanks for the explanation.
        Working...