Skip to content

Page return type mismatch from client.People.List() #20

Description

@sulbig

I am trying to do a simple fetch of all people -- with pagination -- using the following example code, but I am getting a compiler error.

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/WebexCommunity/webex-go-sdk/v2"
	"github.com/WebexCommunity/webex-go-sdk/v2/people"
)

func main() {
	accessToken := os.Getenv("WEBEX_ACCESS_TOKEN")
	if accessToken == "" {
		log.Fatal("WEBEX_ACCESS_TOKEN environment variable is required")
	}

	client, err := webex.NewClient(accessToken, nil)
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	options := &people.ListOptions{}
	page, err := client.People().List(options)
	if err != nil {
		log.Fatalf("Error listing people: %v", err)
	}

	for {
		for _, person := range page.Items {
			fmt.Printf("Person: %s (%s)\n", person.DisplayName, person.Emails[0])
		}

		if !page.HasNext {
			break
		}

		page, err = page.Next()
		if err != nil {
			log.Fatalf("Error listing people: %v", err)
		}
	}
}

The compiler error is...

./main.go:38:15: cannot use page.Next() (value of type *webexsdk.Page) as *people.PeoplePage value in assignment

Am I doing something wrong?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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