Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-16619

SQL statement execution when call item.create method via API

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 4.0.12
    • API (A)
    • None
    • OS: Centos 7.x
      RDBMS: PostgreSQL 9.6
      PHP: 7.1.24

      When I'm trying to create item for the host via API, I'm get  the following error:

      {{{}}
        "jsonrpc": "2.0",
        "error": {
          "code": -32500,
          "message": "Application error.",
          "data": "SQL statement execution has failed \"INSERT INTO items (name,key_,hostid,type,value_type,interfaceid,delay,master_itemid,flags,query_fields,headers,itemid) VALUES ('{$JMX.1} Heap Memory','jmx.HeapMemoryUsage.used[\"\{$JMX.1.PORT}\"]','10930','0','0','1348','60s',NULL,'0','','','74461')\"."
        },
        "id": 1
      }

      I try to do it via bash script with POST curl request. I use the following curl cmd options:

      curl -s -k -X POST -H "Content-Type:application/json" --data "$ZabbixAPIRequest" "$ZBX_API_URL"

      where:

      $ZabbixAPIRequest - variable, which contain the following JSON

      {{{}}
          "jsonrpc": "2.0",
          "method": "item.create",
          "params": {
              "name": "{$JMX.1} Heap Memory",
              "key": "jmx.HeapMemoryUsage.used["\{$JMX.1.PORT}"]",
              "hostid": "10930",
              "type": "0",
              "value_type": "0",
              "interfaceid": "1348",
              "applications": [
                  "8293"
              ],
              "delay": "60s"
          },
          "auth": "xxxx252yyyy68fxxxa3bzzz0xxxxx",
          "id": 1
      }

      $ZBX_API_URL - https://zabbix.....com/api_jsonrpc.php - URL to zabbix API on our server

      I've successfully created host, application for newly created host, user's macroses , first, before attempt of create item.

       

            zabbix.dev Zabbix Development Team
            Syrov Dmitry
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: