Get channel messages Teams - limited to 100

I need to get all channel messages and I am limited to 100 messages, I am not allowed to put a higher value, since Uipath will throw an error.

However my channel has more than 100 messages… Any ideas how can I fetch all messages?
“Message: The limit of ‘100’ for Top query has been exceeded. The value from the incoming request is ‘1000’”

In Graph API there is a link to the next page

You have to place repeat requests until you have no more messages. Here is one way you can do it:

Each message has a timestamp. The latest message will have the latestModifiedDateTime.

At the end of each batch of 100 you have to grab that value and then on the next request fetch the next 100 messages created on or after that date.

1 Like

Actually your screenshot shows the GetMessageReplies activity. According to the documentation the limit for GetChannelMessages is only 50!

See also: Microsoft Teams List Channel Messages - Microsoft Q&A

No idea how to circumvent this. Let us know if you find out more on this issue

yes, but in UiPath Get Messages . Get Message replies Activity is not possible to put any filter when getting messages, only limit, which is useless in my case.

The only option remained is to use HTTP requests, instead of the already built-in Microsoft Teams activities

Both channel messages and channel message replies have a limitation and UiPath Teams Activities does not handle pagination.

Yep, it’s not always that these activities will have everything we need -at least in the first version.

APIs may be the best universal course of action if you want to build versatile applications that are not limited by any kind of feature that is currently unavailable in a UiPath activity.

My solution was to import Microsoft.Identiti.Client package and using Invoke Code activity I wrote the following lines in C#:

string[] scopes = new string[] {
 var app = Microsoft.Identity.Client.PublicClientApplicationBuilder.Create(clientId)
 Microsoft.Identity.Client.AuthenticationResult result =  app.AcquireTokenByIntegratedWindowsAuth(scopes)
 accessToken = result.AccessToken;

This way I have received the access token and used it further in my HTTP requests.