Skip to content

Get-MgTeamChannelMessage limits to 50 #874

Closed

Description

I need to generate an array of all messages in a channel but this command is apparently limited to 50 messages.
Get-MgTeamChannelMessage -TeamId $team.id -ChannelId $channel.id -PageSize 50
returns 50 message but
Get-MgTeamChannelMessage -TeamId $team.id -ChannelId $channel.id -PageSize 51
throws the error "Limit of '50' for Top Query has been exceeded." I didn't specify a Top query
if you use the -Top parameter with anything over 50 you get the same error, the -All parameter does the same thing.

I understand API limits but having to get 50 messages, then do another query with a -Skip 50 and add to the array, then do a -Skip 100 (rinse repeat) seems ridiculous!

I can't find any workaround for this in the relatively sparse documentation for these modules.

Activity

  1. Clifra-Jones commented on Sep 24, 2021

    @Clifra-Jones
    Author

    OK I did figure out a work around by looking at the C# code.

    Get-MgTeamChannelMessage -TeamId $Team.Id -ChannelId $Channel.Id -PageSize 50 -All

    But that just seems stupid. If the max allowed page size is 50 (The C# code says the max is 999) then the -All parameter should automatically set the -PageSize to 50, we should not have to provide it is we want ALL messages.

  2. peombwa commented on Sep 29, 2021

    @peombwa
    Member

    We should update the paging logic to use the default payload count as the initial pageSize then follow the nextLink until the last item is retrieved.

    The current implementation uses a default pageSize of 100, which conflicts with Teams' max allowed pageSize of 50. Note, the max allowed pageSize varies from service to service. Most services generally accept a pageSize of 100, but it appears Teams is an exception.

    Note to self: Should AGS formalize a default page size/$top for all workloads?

  3. added this to the Backlog milestone on Sep 29, 2021
  4. peombwa commented on Jul 1, 2022

    @peombwa
    Member

    Will be fixed by #1361.

    Closing as duplicate of #1351.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions