'Is there an api endpoint to list files in private chat?

I am looking for a way to get the number of files in a private chat using the Microsoft Graph API.

Currently I can get the messages from private chat using:

beta/users/{user_id}/chats/{chat_id}/messages

Another API is the 'List children of a driveItem' - https://docs.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http to get the number of files for a channel - that looks like this:

/teams/{team_id}/channels/{channel_id}/messages

And get a response like this:

value ': [{
' id ': ' 123456'},
' user ': {' displayName ': ' Username ',
' folder ': {' childCount ': 9}]

And I can access the childCount parameter

Problem is, that it receives only team ID - and not chat ID.

So I am looking for an API that just receive the chat ID and send in response the information, just the the 'List children of a driveItem' API

If there is a way to get the drive-id of a private chat it would be good as well since I will use the same list children API and it should work, right?

Thanks!



Solution 1:[1]

Chats threads don't have a drive as only teams have a drive associated with them. However you can get the list of all chat messages which contains attachments[] for files shared in private chat using below API:

beta/users/{user_id}/chats/{chat_id}/messages

So here ChatId is available along with the attachments[] like below:

"attachments": [ { "id": "4a000672-3234-4306-8c01-b6e6fea43f22", "contentType": "reference", "contentUrl": "https://m365x645306.sharepoint.com/sites/SiteName/Shared Documents/Test/My-Tasks.csv", "content": null, "name": "My-Tasks.csv", "thumbnailUrl": null } ],

So based on the attachments, you can get the number of files attached in this private chat along with it's SharePoint content URL.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman