2
votes

In the wake of the new beta API for it, I have written a script that exports Teams one to one chats to a text file. This is so that, after migrating to a new tenant, my users can have their chat history in some place. After finishing the code and trying it on my first user, I found that I can only pull the most recent 20 messages per chat.

Here is the API command I am using: https://github.com/microsoftgraph/microsoft-graph-docs/blob/master/api-reference/beta/api/chatmessage-list.md

Is there any way to turn off throttling, or is there some step I am missing so that I can export all chat messages? I'm new to the Graph API.

2

2 Answers

1
votes

It is not causing because of throttling issue.

Graph API implements paging for certain API. For List chat messages API, 20 message is the limit currently. The API response has "@odata.nextLink" property with the link to fetch next 20 messages.

Sample Response

"@odata.context": "https://graph.microsoft.com/beta/LongUrlShort/messages",
"@odata.count": 20,
"@odata.nextLink": "https://graph.microsoft.com/beta/me/chats/LongUrlhSort",

So you need to handle it while calling the API. You can make the API call in loop and get all the records.

1
votes

You can use the query parameter ?top=30 to get the top 30 messages. There is no documentation on this.

Here is the reference URL. https://techcommunity.microsoft.com/t5/microsoft-teams/ms-teams-graph-api-number-of-messages-returned-by-get-messages/m-p/819565

In my case, I found that it also has a limit of 50.

i.e.

?top=50