Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

'Annotations' method uses the wrong URL path #56

Open
mdb opened this issue Jul 19, 2020 · 0 comments
Open

'Annotations' method uses the wrong URL path #56

mdb opened this issue Jul 19, 2020 · 0 comments

Comments

@mdb
Copy link
Contributor

mdb commented Jul 19, 2020

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:

  1. Run a local Grafana:

    docker run -p 127.0.0.1:3000:3000 "grafana/grafana:$(GRAFANA_VERSION)"
  2. 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)
    }
  3. Run the code with GF_LOG=1:

    GF_LOG=1 go run ~/Desktop/main.go
  4. Note that the request URL path is api/annotation, despite that the Grafana API docs specify it as api/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.

mdb added a commit to mdb/go-grafana-api that referenced this issue Jul 19, 2020
mdb added a commit to mdb/go-grafana-api that referenced this issue Jul 19, 2020
This seeks to address issue nytm#58.

It also illustrates the problem outlined in issue nytm#56, as
`TestAnnotationsIntegration` will fail until PR nytm#57 is merged.
mdb added a commit to mdb/go-grafana-api that referenced this issue Jul 19, 2020
This seeks to address issue nytm#58.

It also illustrates the problem outlined in issue nytm#56, as
`TestAnnotationsIntegration` will fail until PR nytm#57 is merged.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant