func (api *API) Call(method string, params interface{}) (Response, error) {
	var response Response
	b, err := api.callBytes(method, params)
	if err != nil {
		return response, err
	}
	err = json.Unmarshal(b, &response)
	if err != nil {
		return response, err
	}
	return response, nil
}
Calls specified API method. Uses api.Auth if not empty.
err is something network or marshaling related. Caller should inspect response.Error to get API error.
package zabbix
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"sync/atomic"
)
type (
	Params map[string]interface{}
)
type request struct {
	Jsonrpc string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
	Auth    string      `json:"auth,omitempty"`
	Id      int32       `json:"id"`
}
type Response struct {
	Jsonrpc string      `json:"jsonrpc"`
	Error   *Error      `json:"error"`
	Result  interface{} `json:"result"`
	Id      int32       `json:"id"`
}
type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data"`
}
func (e *Error) Error() string {
	return fmt.Sprintf("%d (%s): %s", e.Code, e.Message, e.Data)
}
type ExpectedOneResult int
func (e *ExpectedOneResult) Error() string {
	return fmt.Sprintf("Expected exactly one result, got %d.", *e)
}
type ExpectedMore struct {
	Expected int
	Got      int
}
func (e *ExpectedMore) Error() string {
	return fmt.Sprintf("Expected %d, got %d.", e.Expected, e.Got)
}
type API struct {
	Auth   string       
	Logger *log.Logger  
	url    string
	c      http.Client
	id     int32
}
func NewAPI(url string) (api *API) {
	return &API{url: url, c: http.Client{}}
}
func (api *API) SetClient(c *http.Client) {
	api.c = *c
}
func (api *API) printf(format string, v ...interface{}) {
	if api.Logger != nil {
		api.Logger.Printf(format, v...)
	}
}
func (api *API) callBytes(method string, params interface{}) ([]byte, error) {
	id := atomic.AddInt32(&api.id, 1)
	jsonobj := request{"2.0", method, params, api.Auth, id}
	b, err := json.Marshal(jsonobj)
	if err != nil {
		return nil, err
	}
	api.printf("Request (POST): %s", b)
	req, err := http.NewRequest("POST", api.url, bytes.NewReader(b))
	if err != nil {
		return nil, err
	}
	req.ContentLength = int64(len(b))
	req.Header.Add("Content-Type", "application/json-rpc")
	res, err := api.c.Do(req)
	if err != nil {
		api.printf("Error   : %s", err)
		return nil, err
	}
	defer res.Body.Close()
	b, err = ioutil.ReadAll(res.Body)
	if err != nil {
		return nil, err
	}
	api.printf("Response (%d): %s", res.StatusCode, b)
	return b, nil
}