I'm using the Microsoft.Graph NuGet package v1.4 to connect to Microsoft Graph. Setting up the connection works fine and I'm able to connect and retrieve my contacts:
var client = AuthenticationHelper.GetAuthenticatedClient();
var contacts = await client.Me.Contacts.Request().GetAsync();
This works like a charm and I'm able to retrieve my contacts. Now I'm looking to delete some of my contacts ( my duplicates in fact ). The REST methods are there:
Described here:
DELETE https://graph.windows.net/myorganization/contacts/{object_id}[?api-version]
But I'm not able to do it through the NuGet package. Is this not implemented in the .NET API?
Looks like you are mixing and matching a few things here. So in Microsoft Graph, we have the notion of personal (or my) contacts. which you are able to find with the nuget package - it should support delete too. But then you are looking at the Azure AD Graph contacts API documentation, which is different (and is about organizational contacts only).
The documentation you want is here: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/contact
If you also want to manage organizational contacts (different from personal contacts), this is only available in /beta (preview) and is not exposed through the Microsoft Graph nuget (since we currently only expose v1.0 GA API through the client libraries). I just noticed that while we have org contacts documented (in GitHub), it's not in the table of contents, so I'll file a bug for this.
UPDATE (based on comment): Please see https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/contact_delete for info on deleting personal contacts. This should also be available through the client library, my guess is through a DeleteAsync() method on a selected contact.
Hope this helps,
Related
Whenever I query the Teams endpoint in Microsoft Graph:
GET https://graph.microsoft.com/beta/teams/{id}
I get the following error:
AccessDenied - Failed to execute Skype backend request GetThreadRequest.
The permissions are set according to the documentation. (Group.Read.All - delegated permission)
Querying https://graph.microsoft.com/beta/groups/{id} is working while with the same access token https://graph.microsoft.com/beta/teams/{id} isn't.
I tried it with my own application and in the Graph Explorer. Both ways didnt't work for me. However using Graph Explorer with the sample account is working. Is there maybe another permission needed which is not yet documented?
Currently it's a requirement that the person using the Graph APIs (and the PowerShell cmdlets that use them under the covers) must be a member of the team whose information they are trying to retrieve. This is the second-most popular ask for users of our cmdlets, and we are close to resolving it. We expect this to be fixed by the end of September 2018, with write APIs/commands coming a few weeks later than read APIs/commands.
I'm trying to query the Global Address List using Microsoft Graph. I've worked with and adapted the sample code from https://github.com/microsoftgraph/console-csharp-snippets-sample.git -- however, I'm still having trouble. I've seen this article -- Global Address List Graph API -- which indicates I need to use the "/contacts" endpoint. However, I don't see how this helps me when I'm using the Microsoft.Graph library. Is there some method or collection within the Microsoft.Graph library that will allow me to read the GAL?
"GAL" is a MAPI concept that doesn't really apply to Graph. With Graph, you just read the users or contacts in your company's Active Directory. By combining both lists, you come close to what you'd see in the GAL in a MAPI client.
To do that, you would list users as doc'ed here: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_list
Using the library, I believe this will get you started:
client.Users.Request().GetAsync();
For contacts, it's a lot trickier with the Graph library. Organizational contacts are only supported in the beta version of Microsoft Graph, which the client library doesn't support unfortunately. (See this issue for info). Michael Mainer did a write up of how you can generate your own beta version of the library if you're interested.
The info on querying organizational contacts is found here: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/orgcontact.
As of late 2021, doesn't appear to be an easy "Export Global Address List" API from Microsoft. There appear to be manual methods (e.g. using the Exchange Admin interface) but nothing programmatic.
Below is broad strokes exercise for creating an approximation (that may be sufficient for your needs). A more accurate exercise may be to export the GAL from a official client (e.g. Outlook/Outlook Web/Exchange Admin interface). Its possible that in some cases the GAL is user specific which may make GAL export concept significantly more involved.
GAL export exercise:
APIs:
MS Graph API (available via HTTP, e.g. GET/POST)
Users
Groups
Some of the above only allowed certain properties accessible by individual record query - I needed to get the whole list then iterate through each record one by one to get all needed properties.
Exchange Powershell (available via Powershell)
Get Mailbox (for flags not exposed by Graph/Users)
Get-DistributionGroup (for flags not exposed by Graph/Groups)
Azure Functions can be used to run these queries serverless/"API-ified". Azure App Registration can be used as OAuth app that can be granted the permissions to access the above. Microsoft Graph Explorer is handy for testing Graph requests.
Put it together:
Smash the datasets together and then filter out on fields. Some flags are:
hideFromAddressLists
hideFromOutlookClients
HiddenFromAddressListsEnabled
showInAddressList,
some conditions you have to manually check for, e.g.
if no provisioned plans (i.e. unlicensed)
if no email address
etc.
Office 365 administration center allows to create organizational contacts which are shared with all users in organization.
In MS Graph documentation API of this functionality is badly documented and located in BETA section. Moreover, there is no command to create such a contact: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/orgcontact
It looks like in Graph this functionality was not implemented. Using typical POST request to the /beta/contacts ends with an error response in Json structure: Unsupported resource type 'Contact' for operation 'Create'.
Note 1: I don't have any user logged in. My application uses service/daemon authentication.
Is there any other way to create organizational contact?
At this time, creating new orgContact objects isn't supported by the Graph API. You also cannot create organizational contacts with the Azure AD Graph API. For more information about organizational contacts, including how they are created in your tenant, see the Contact Entity documentation.
Organization Contacts are documented in the beta section because this API is in fact still in beta. I'm sorry you ran into issues here but with any beta endpoint there is always likelihood of missing/broken features and sparse documentation. There is also a substantial likelihood of breaking changes being rolled out to beta endpoints. As such, we do not recommend using them in production scenarios.
I'm creating an office group using Microsoft Graph API. After that I would like to create a Microsoft Team which is associated with the group. I can do this step manually, but I'm wondering if it's also possible to do so via API.
Graph API doesn't seem to support Microsoft Teams yet. Am I correct?
You are correct, Teams is not yet part of the Graph API, nor do we yet have support for creating Teams. Both are on the road map, but I do not have an ETA for you at this time.
Actually you can do this semi-automatically using the beta API on Skype. Here is a GitHub project doing this from PowerShell: https://github.com/sanderdewit/teams-module
This approach is semi-automatically, because you need a user to sign-in once via a pop-up window. And for sure this is not a supported scenario.
Like azure ad graph API: https://msdn.microsoft.com/en-us/Library/Azure/Ad/Graph/api/functions-and-actions#getAvailableExtensionProperties
Is there any API to get all available extension properties in Microsoft graph?
Now we only can get the extension properties registered in current tenant application via /applications//extensionProperties
https://graph.microsoft.io/en-us/docs/api-reference/beta/api/application_list_extensionproperties
But how to get extension properties of multiple-tenant application consented from other tenant?
Thanks
No, we haven't exposed that particular API in Microsoft Graph.
(UPDATED 3/12/07) We've introduced an updated extensibility story for Microsoft Graph that should be a little easier to use, more discoverable and consistent across Microsoft Graph (i.e. not just for Directory entity types). For more information check out this blog post.
UPDATE: New video explaining our new extensibility story. Hopefully you'll be able to get your hands on this next month.