Skip to content

GetHost inventory_mode type error #57

@zhaojinxin409

Description

@zhaojinxin409

Calling GetHost always error: Error decoding JSON response body: json: cannot unmarshal string into Go struct field Host.inventory_mode of type int

MyCode

hosts, err := session.GetHosts(zabbix.HostGetParams{
		GetParameters: zabbix.GetParameters{
			ResultLimit: 10,
		},
	})
	fmt.Println(hosts, err)

Output:

[] Error decoding JSON response body: json: cannot unmarshal string into Go struct field Host.inventory_mode of type int

Reason

I found that even though the Host Object's inventory_mode is int, but the response of zabbix convert it into string of integer, like :

  {
      "jsonrpc": "2.0",
      "result": [
            {
                 "inventory_mode": "-1"
             }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions