MS Teams Graph API : Number of messages returned by GET /messages

Copper Contributor

Hi,

 

We are working in an integration with Graph Api and Teams, but testing 

GET /teams/{id}/channels/{id}/messages

we get a number of messages that we don't understand.

We have a channel with around 35 messages. When we call GET /teams/{id}/channels/{id}/messages, we get just 7 messages. Then we call GET /teams/{id}/channels/{id}/messages?top=20, and we get 7 messages, but if we call GET /teams/{id}/channels/{id}/messages?top=100, then we get 13 messages and if we continue with @odata.nextLink url, then we get 24 and no @odata.nextLink, so thats all the messages.

 

Using just /messages and @odata.nextLink, we get 7, then 1, then 13, then 16 and last page with 0.

 

We suspect that is all the events in the channel like "added/deleted member" "renamed channel" (we got a lot of those while testing) ... and then filters just the messages, and thats why we get different amount in every page of results

 

So does anyone know how /messages works to return those amount of messages?

how does /messages filter in the channel to just get 7 in the first place?

 

Thank you in advance!

3 Replies

There's a reason this endpoint is still Beta, there has been various issues with it. Moreover it doesn't support the regular OData parameters and you are forced to work with $top only, which as you've already noticed is not really reliable. Just spam the @odata.nextLink, you need to handle it anyway if you want to cover all messages. And don't forget that no replies are returned by this query.

@Vasil Michev Thanks for your answer. I know... we were expecting a flag or a count for replies in the response for every message to avoid requesting every message again just to check if there are replies... i hope they add that soon.

 

We will have to work with nextLink by now...