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

Unable to create a new host via the API when specifying templates

    XMLWordPrintable

Details

    • Problem report
    • Status: Closed
    • Trivial
    • Resolution: Won't fix
    • 5.0.11
    • None
    • Frontend (F)
    • PHP 7.2.24
      nginx/1.16.1
      Zabbix frontend: 5.0.11

    Description

      Steps to reproduce:

      1. Add new host via the API, the request must contain template IDs, for example:
        host=testhost,
        status=0,
        groups=[\{'groupid': 18}, \{'groupid': 20}, \{'groupid': 143}],
        interfaces=...,
        proxy_hostid='10123',
        templates=['12345']

      Result:

      Response from the Frontend:
      {{{}}
      {{'code': -32500, }}
      {{'message': 'Application error.', }}
      {{'data': 'No permissions to referred object or it does not exist!', }}
      'debug': [
      {{{}}
      {{'file': '/usr/share/zabbix/include/classes/api/services/CHostBase.php', 'line': 49, }}
      {{'function': 'exception', }}
      {{'class': 'CApiService', }}
      {{'type': '::', }}
      'args': [120, 'No permissions to referred object or it does not exist!']}

      In the nginx logs:

      2021/06/02 14:35:59 [error] 21#0: *619655 FastCGI sent in stderr: "PHP message: PHP Warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: ""
      LINE 1: ...(r.permission)>0 AND MAX(r.permission)>='2') AND h.hostid=''
      {{ ^ in /usr/share/zabbix/include/db.inc.php on line 247" while reading response header from upstream, client: X.X.X.X, server: zabbix, request: "POST /api_jsonrpc.php HTTP/1.1", upstream: "fastcgi://unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock:", host: "zabbix"}}
      {{ Expected:}}
      }}{{

      It should add the host with the linked templates.

      When I remove the "templates" field from the request, and I add the templates in a separate request, when the host already exists, it's working fine.

      Attachments

        Activity

          People

            ssimonenko Sergey Simonenko
            kovax Daniel Kovacs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: