Graph API for accessing teams and team's groups to pull documents - microsoft-graph-api

I am working on asset management system in which my application needs to pull specific documents of all the employees being stored by them on teams or any teams group.
Using graph API or any other medium, how can I achieve the same. Any suggestions or pointers will be helpful to start with.

Teams has a associated Group.
So you need to get the list of all the Teams first through (reference):
GET https://graph.microsoft.com/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')
Then you can traverse this list to get the Group (Teams) id.
Get the channels in an Teams like this (reference):
GET https://graph.microsoft.com/v1.0/teams/{Group id}/channels
Record the channels' name.
Now use this call to get the files stored in a Teams channel (reference):
GET https://graph.microsoft.com/v1.0/groups/{Group id}/drive/root:/{channel name}:/children
You need to implement multiple loops to get all the files stored in Teams.
UPDATE:
Using the following request to list the items in the Teams:
GET https://graph.microsoft.com/v1.0/groups/{Group id}/drive/root/children
You can get the item id of General folder from the response.
Then you can get the files under General folder through:
GET https://graph.microsoft.com/v1.0/groups/{Group id}/drive/items/{item id}/children

Related

Best ways to fetch files/folders that shared by different people with same name using 'SharedWithMe' Microsoft Graph API

I can fetch all the Shared Items by making a GET request.
Get https://graph.microsoft.com/v1.0/me/drive/sharedWithMe
However, if two different people shared two items with the same name I'm just getting one item.
I can modify the names of the items using C# before fetching them but I want to know if there's a better way to get the duplicated items using Microsoft Graph API.

Microsoft Graph Unified Contacts List

Is it possible to create Exchange contacts list which will be shared across the whole organisation using Graph API?
These contacts are not the part of the organisation.
I know we can add contact to user's contact list, however was not able to find a way to have a contact which will be shared across the whole organisation.
POST /me/contacts
POST /users/{id | userPrincipalName}/contacts
POST /me/contactFolders/{contactFolderId}/contacts
POST /users/{id | userPrincipalName}/contactFolders/{contactFolderId}/contacts
I am aware that contacts are shared if the contact is within organisation and if they are in Active Directory Domain Services (AD DS). However these contacts are outside of the org.
Mail Enabled directory contacts (which are stored in AD) are available using the organizational contacts endpoint https://learn.microsoft.com/en-us/graph/api/orgcontact-list?view=graph-rest-1.0&tabs=http. However they don't allow you to create Org contacts in the Graph there's a uservoice request for this https://microsoftgraph.uservoice.com/forums/920506-microsoft-graph-feature-requests/suggestions/38083912-make-it-possible-to-create-organizational-contacts (but not looking good at getting this changed)
So the Exchange cmldets are still the only real way of doing this programatically https://learn.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps
eg
New-MailContact -Name "Chris Ashton" -ExternalEmailAddress "chris#tailspintoys.com"
While this does not answer my question directly, one of the solutions would be to have a user which will serve as a master containing all contacts.
This way contacts list would be accessible using following Graph call
GET /users/{id | userPrincipalName}/contacts
The downside of this approach is that whenever new contact is added to personal list it would need to be added to this list as well.

Read deleted group owners with Graph API

Is there any way to list the owners of a recently deleted group with Graph API? I need to build a process with PowerAutomate to inform all the owners that their group is deleted.
With PowerShell I get this far:
Get-UnifiedGroup -Identity $guid -IncludeSoftDeletedGroups
Then I get a list of owners under the ManagedBy property, to bad, they are AD usernames only, not emails.
With Graph, I don't even get this far, I didn't find an an equivalent of the IncludeSoftDeletedGroups parameter and when I query for a deleted group I simply get an error that it doesn't exist. Can somebody please give me a hint?
https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.group
This is the call you need to do to get the recently deletedItems for groups(microsoft.graph.group). Please check this DeletedItems Doc.
Currently, there is no way to get the owners from deleted items, please raise the UserVoice

How to list the deleted contacts by Microsoft Graph API

I want to do a sync action in my client side, so need to know how to get all deleted contact list.
By the api (GET /me/contacts), I could get all contact list
But it wastes much time when the user has large contacts.
This api (GET /me/contacts/{id}) tell us the contact is exist or not.
it is inefficient to check every contacts are deleted or not for me.
Which apis do I use? thanks for your help.
Why not use the delta query preview in the /beta endpoint? That should do what you want.
More efficient way for you to check which contacts were removed is getting just the list of contact ID's and then doing the diff between list of ID's returned by graph, and local list.
You can use query parameters to retrieve just the ID's of the contacts, instead of getting the whole objects.
Method url:
https://graph.microsoft.com/v1.0/me/contacts?$select=id

Display all online users in a Slack channel

New to slack at the moment - I've looked around to see if there's a Slack command to show all online users in a Slack channel but haven't found any.
Would a custom slack command calling a Slack API method eg. users.getPresence be the way to go or is there another way?
Your best bet would be to first retrieve the list of members within the channel using the Web API method channels.info.
Each channel object will contain a members field containing a collection of user IDs -- those who have joined the channel.
You would then have two options depending on your preferences:
1) Use users.list to retrieve a list of all team members (including each user's presence) and narrow list of users down to those listed in the members field from above.
2) or, you could look up each user from that members field, one at a time using users.info.

Resources