Home

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

%3CLINGO-SUB%20id%3D%22lingo-sub-819565%22%20slang%3D%22en-US%22%3EMS%20Teams%20Graph%20API%20%3A%20Number%20of%20messages%20returned%20by%20GET%20%2Fmessages%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-819565%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20working%20in%20an%20integration%20with%20Graph%20Api%20and%20Teams%2C%20but%20testing%26nbsp%3B%3C%2FP%3E%3CP%3EGET%20%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2Fmessages%3C%2FP%3E%3CP%3Ewe%20get%20a%20number%20of%20messages%20that%20we%20don't%20understand.%3C%2FP%3E%3CP%3EWe%20have%20a%20channel%20with%20around%2035%20messages.%20When%20we%20call%26nbsp%3BGET%20%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2Fmessages%2C%20we%20get%20just%207%20messages.%20Then%20we%20call%26nbsp%3BGET%20%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2Fmessages%3Ftop%3D20%2C%20and%20we%20get%207%20messages%2C%20but%20if%20we%20call%26nbsp%3BGET%20%2Fteams%2F%7Bid%7D%2Fchannels%2F%7Bid%7D%2Fmessages%3Ftop%3D100%2C%20then%20we%20get%2013%20messages%20and%20if%20we%20continue%20with%26nbsp%3B%40odata.nextLink%20url%2C%20then%20we%20get%2024%20and%20no%26nbsp%3B%40odata.nextLink%2C%20so%20thats%20all%20the%20messages.%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20just%20%2Fmessages%20and%26nbsp%3B%40odata.nextLink%2C%20we%20get%207%2C%20then%201%2C%20then%2013%2C%20then%2016%20and%20last%20page%20with%200.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20suspect%20that%20is%20all%20the%20events%20in%20the%20channel%20like%20%22added%2Fdeleted%20member%22%20%22renamed%20channel%22%20(we%20got%20a%20lot%20of%20those%20while%20testing)%20...%20and%20then%20filters%20just%20the%20messages%2C%20and%20thats%20why%20we%20get%20different%20amount%20in%20every%20page%20of%20results%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20does%20anyone%20know%20how%20%2Fmessages%20works%20to%20return%20those%20amount%20of%20messages%3F%3C%2FP%3E%3CP%3Ehow%20does%20%2Fmessages%20filter%20in%20the%20channel%20to%20just%20get%207%20in%20the%20first%20place%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-819565%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EConversations%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHow-to%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-819946%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Teams%20Graph%20API%20%3A%20Number%20of%20messages%20returned%20by%20GET%20%2Fmessages%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-819946%22%20slang%3D%22en-US%22%3E%40alexander%20holmeset%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-820496%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Teams%20Graph%20API%20%3A%20Number%20of%20messages%20returned%20by%20GET%20%2Fmessages%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-820496%22%20slang%3D%22en-US%22%3E%3CP%3EThere's%20a%20reason%20this%20endpoint%20is%20still%20Beta%2C%20there%20has%20been%20various%20issues%20with%20it.%20Moreover%20it%20doesn't%20support%20the%20regular%20OData%20parameters%20and%20you%20are%20forced%20to%20work%20with%20%24top%20only%2C%20which%20as%20you've%20already%20noticed%20is%20not%20really%20reliable.%20Just%20spam%20the%26nbsp%3B%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%40odata.nextLink%3C%2FFONT%3E%2C%20you%20need%20to%20handle%20it%20anyway%20if%20you%20want%20to%20cover%20all%20messages.%20And%20don't%20forget%20that%20no%20replies%20are%20returned%20by%20this%20query.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-822459%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Teams%20Graph%20API%20%3A%20Number%20of%20messages%20returned%20by%20GET%20%2Fmessages%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-822459%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3BThanks%20for%20your%20answer.%20I%20know...%20we%20were%20expecting%20a%20flag%20or%20a%20count%20for%20replies%20in%20the%20response%20for%20every%20message%20to%20avoid%20requesting%20every%20message%20again%20just%20to%20check%20if%20there%20are%20replies...%20i%20hope%20they%20add%20that%26nbsp%3Bsoon.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20will%20have%20to%20work%20with%20nextLink%20by%20now...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
jaimeirala
New 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...

 

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies