go-atlassian icon indicating copy to clipboard operation
go-atlassian copied to clipboard

Confluence V2 Space.Bulk cannot unmarshal string into Go struct field SpaceSchemeV2.results.id of type int

Open piyushwadhwanicppib opened this issue 1 year ago • 2 comments

go-atlassian version

go-atlassian component

  • [ ] Jira Software Cloud
  • [ ] Jira Agile Cloud
  • [ ] Jira Service Management Cloud
  • [X] Confluence Cloud
  • [ ] Atlassian Admin Cloud

Describe the bug :bug: while running example mentioned in https://docs.go-atlassian.io/confluence-cloud/v2/space

cannot unmarshal string into Go struct field SpaceSchemeV2.results.id of type int

To Reproduce :construction:

https://docs.go-atlassian.io/confluence-cloud/v2/space

Expected behavior :white_check_mark:

spaces should be return

Screenshots :page_facing_up:

Additional context Add any other context about the problem here.

Code snippet

package main

import (
	"context"
	"fmt"
	confluence "github.com/ctreminiom/go-atlassian/confluence/v2"
	"github.com/ctreminiom/go-atlassian/pkg/infra/models"
	"log"
	"net/url"
	"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")

	options := &models.GetSpacesOptionSchemeV2{
		IDs:               nil,
		Keys:              nil,
		Type:              "",
		Status:            "",
		Labels:            nil,
		Sort:              "",
		DescriptionFormat: "",
		SerializeIDs:      false,
	}

	var cursor string
	for {

		spaces, response, err := instance.Space.Bulk(context.Background(), options, cursor, 20)
		if err != nil {
			log.Fatal(err)
		}

		for _, space := range spaces.Results {
			fmt.Println(space)
		}

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

		if spaces.Links.Next == "" {
			break
		}

		values, err := url.ParseQuery(spaces.Links.Next)
		if err != nil {
			log.Fatal(err)
		}

		_, containsCursor := values["cursor"]
		if containsCursor {
			cursor = values["cursor"][0]
		}
	}
}

piyushwadhwanicppib avatar Feb 21 '24 04:02 piyushwadhwanicppib

This has already been fixed , can we please create a new release ?

piyushwadhwanicppib avatar Feb 21 '24 04:02 piyushwadhwanicppib

Hi @piyushwadhwanicppib, I just release the version v1.6.0.

Can you please confirm the new behavior?

Thanks

ctreminiom avatar Mar 08 '24 04:03 ctreminiom