Top seems to be ignored
pmmaga opened this issue · 2 comments
pmmaga commented
I'm trying to use Top() on a query and the query string part of the request seems to simply be ignored. When I check the URL to debug, the query string is present, but the reply seems to be ignoring it.
Sample code:
graphClient := msgraph.NewClient(...)
ct := graphClient.Teams().ID(teamid).Channels().ID(channel).Messages().Request()
ct.Top(20)
fmt.Println("calling url: %s", ct.URL()) // calling url: https://graph.microsoft.com/beta/teams/.../channels/.../messages?%24top=20
rct, err := ct.Get(ctx)
fmt.Println("got %#v messages", len(rct)) // got 592 messages
yaegashi commented
Top() specifies the page size, that is a number of items returned by a single GET operation: https://docs.microsoft.com/en-us/graph/query-parameters#top-parameter
You can use GetN(ctx, N) to specify how many pages you want. N=0 means it should get over all pages. Get(ctx) is equivalent to GetN(ctx, 0).
pmmaga commented
GetN did the trick. Thank you