Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content.Search() results incomplete #113

Closed
1 of 5 tasks
timbrammer910 opened this issue Mar 17, 2022 · 2 comments
Closed
1 of 5 tasks

Content.Search() results incomplete #113

timbrammer910 opened this issue Mar 17, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@timbrammer910
Copy link

timbrammer910 commented Mar 17, 2022

go-atlassian version
v1.4.2

go-atlassian component

  • Jira Software Cloud
  • Jira Agile Cloud
  • Jira Service Management Cloud
  • Confluence Cloud
  • Atlassian Admin Cloud

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

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

Expected behavior
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)
	}
}
@timbrammer910 timbrammer910 added the bug Something isn't working label Mar 17, 2022
@Engerim
Copy link

Engerim commented Mar 17, 2022

in 1.4.2 is the wrong search endpoint used,

var endpoint = fmt.Sprintf("/wiki/rest/api/search?%v", query.Encode())

in the main branch this is fixed to use the content search path

@ctreminiom
Copy link
Owner

Hi @timbrammer910

It was a bug 🐞 but the PR #103 fixed the Content.Search() method.

FYI: I just released the version v1.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants