go-grafana-api
go-grafana-api copied to clipboard
'Annotations' method uses the wrong URL path
Describe the bug
Currently, the Annotations
method performs a GET api/annotation
request, though it should perform a GET api/annotations
request.
To reproduce Steps to reproduce the behavior:
-
Run a local Grafana:
docker run -p 127.0.0.1:3000:3000 "grafana/grafana:$(GRAFANA_VERSION)"
-
Create a basic go package to perform an
Annotations
request:package main import ( "fmt" "net/url" gapi "github.com/nytm/go-grafana-api" ) func main() { c, err := gapi.New("admin:admin", "http://localhost:3000") if err != nil { panic(err) } as, err := c.Annotations(url.Values{}) if err != nil { panic(err) } fmt.Println(as) }
-
Run the code with
GF_LOG=1
:GF_LOG=1 go run ~/Desktop/main.go
-
Note that the request URL path is
api/annotation
, despite that the Grafana API docs specify it asapi/annotations
, and that the response body is HTML rather than JSON:$ GF_LOG=1 go run main.go 2020/07/19 09:48:12 request (GET) to http://admin:admin@localhost:3000/api/annotation with no body data 2020/07/19 09:48:13 response status 200 with body <!DOCTYPE html> <html lang="en"> ... panic: invalid character '<' looking for beginning of value
Expected behavior
The Annotations
method should perform a GET api/annotations
request and return the annotations.