ctreminiom / go-atlassian

✨ Golang Client Library for Atlassian Cloud.
https://docs.go-atlassian.io
MIT License
131 stars 34 forks source link

Content.Search() results incomplete #113

Closed timbrammer910 closed 2 years ago

timbrammer910 commented 2 years ago

go-atlassian version v1.4.2

go-atlassian component

Describe the bug :bug: Content.Search() does not return fields beyond the title of the content.

To Reproduce :construction: Copy example code - https://docs.go-atlassian.io/confluence-cloud/content#search-contents-by-cql Update host, username, password values

Expected behavior :white_check_mark: Return pages with values in models.ContentScheme

Actual behavior: Meeting notes <nil> <nil> <nil> <nil> <nil> [] <nil> <nil> <nil> []}

Additional context Using Content.Get with an ID works fine.

Code snippet

package main

import (
    "context"
    "github.com/ctreminiom/go-atlassian/confluence"
    "log"
    "net/http"
    "os"
)

func main()  {

    var (
        host  = os.Getenv("HOST")
        mail  = os.Getenv("MAIL")
        token = os.Getenv("TOKEN")
    )

    instance, err := confluence.New(nil, host)
    if err != nil {
        log.Fatal(err)
    }

    instance.Auth.SetBasicAuth(mail, token)
    instance.Auth.SetUserAgent("curl/7.54.0")

    var (
        cql = "type=page"
        cqlContext = ""
        expand = []string{"childTypes.all", "metadata.labels"}
        maxResults = 50
    )

    contentPage, response, err := instance.Content.Search(context.Background(), cql, cqlContext, expand, "", maxResults)
    if err != nil {

        if response.Code == http.StatusBadRequest {
            log.Println(response.API)
        }
        log.Fatal(err)
    }

    log.Println("Endpoint:", response.Endpoint)
    log.Println("Status Code:", response.Code)
    log.Println(contentPage.Links.Next)

    for _, content := range contentPage.Results {
        log.Printf("%v", content)
    }
}
Engerim commented 2 years ago

in 1.4.2 is the wrong search endpoint used, https://github.com/ctreminiom/go-atlassian/blob/98b39a3e15b3c293703c8f12287dd8c95de657ea/confluence/content.go#L140 in the main branch this is fixed to use the content search path

ctreminiom commented 2 years ago

Hi @timbrammer910

It was a bug 🐞 but the PR https://github.com/ctreminiom/go-atlassian/pull/103 fixed the Content.Search() method.

FYI: I just released the version v1.4.3