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

Zabbix returns empty response for API call

XMLWordPrintable

    • Icon: Patch request Patch request
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 6.0.9
    • API (A)
    • None

      Steps to reproduce:

      Make API call for host.create action with this body:

      {
         "jsonrpc":"2.0",
         "method":"host.create",
         "params":{
            "host":"some_host_name",
            "templates":[
               {
                  "templateid":"10712"
               }
            ],
            "groups":[
               {
                  "groupid":"40"
               }
            ],
            "interfaces":[
               {
                  "type":1,
                  "main":1,
                  "useip":1,
                  "ip":"10.11.105.121",
                  "dns":"",
                  "port":10050
               }
            ],
            "auth":"my_token_here",
            "id":1
         }
      } 

      My Python's code:

      def generate_data_for_zabbix_request(self, host_name: str, ip_address: str):
        data = {
          "jsonrpc": "2.0",
          "method": "host.create",
          "params": {
              "host": host_name,
              "templates": [
                  {
                      "templateid": self.template_id
                  }
              ],
              "groups": [
                  {
                      "groupid": self.group_id
                  }
              ],
              "interfaces": [
                  {
                      "type": 1,
                      "main": 1,
                      "useip": 1,
                      "ip": ip_address,
                      "dns": "",
                      "port": 10050
                  }
              ],
              "auth": self.token,
              "id": 1
          }
        }
      ..........
      try:
          return json.dumps(data)
      ..........
      
      def request_to_create_host_in_zabbix(self, host_name: str, ip_address: str):
          try:
              response = requests.post(
                  url=self.zbx_host,
                  headers=self.zbx_headers,
                  data=self.generate_data_for_zabbix_request(host_name, ip_address),
                  timeout=20
              )
      .......
          print(response.status_code, " -- ", response.text)

      Result:
      As a result, I'm getting this output:

      200  –  

      Acually, it doesn't matter how I'm doing this request - via curl or via Python requests library, response will be empty, however, response code always will be 200.

      I'm able to make requests and get token, groupid and templateid via API.

      My Zabbix user role allows all API calls that are possible and has 'Super Admin' user type.

      My Zabbix user also has RW access to all groups.

      No errors in Zabbix server log or HTTP server logs.

      Expected:
      Host will be created or at least any message about possible error will be returned.

            zabbix.dev Zabbix Development Team
            vitalii_bendyna Vitalii Bendyna
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: