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

'Annotations' method uses the wrong URL path #56

Open
@mdb

Description

@mdb

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.

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