We are building an application that integrates office 365 using graph APIs. We need to pull all the office 365 contacts into our system and needs to be in sync.
There is delta API in office to pull only delta changes. We found an issue like we can not pull extended properties(Which includes outlook MPAI fields like mobile phone, assistant phone, etc)
GET https://graph.microsoft.com/v1.0/me/contacts/delta
So office 365 expects the client to make extra API call to get extended properties for each contact?
Means if the user has 1000 contacts, the client has to make 1000 plus API calls to pull the contacts from office365?
There is another contact search API which supports extended properties in a single call. Can we use this to pull the delta changes?
GET https://graph.microsoft.com/v1.0/me/contacts?$filter=lastModifiedDateTime gt '2018-07-28T05:25:32Z'
Please advice us how we can effectively pull office365 contacts
Thanks in advance!
As far as i can see (and observed myself with calendar events) expand is not supported for most delta query calls. See doc for delta query under Optional Query Parameters:
$expand is only suported for the manager and members navigational property for users and groups respectively.
Your filter request is also not supported for delta query. If u use :
GET https://graph.microsoft.com/v1.0/me/contacts/delta?$filter=lastModifiedDateTime gt 2018-07-28T05:25:32Z
You get the following error:
"error":
{
"code": "ErrorInvalidUrlQuery",
"message": "The following parameters are not supported with change tracking over the 'Contacts' resource: '$orderby, $filter, $select, $expand, $search, $top'.",
"innerError":
{
"request-id": "da1174b3-d...",
"date": "2018-08-06T12:45:34"
}
}
Funnily enough select is actually supported (contact delta doc).
Any way it seems like your only choice is to expand the normal contact request for a user.
If there are a lot of changes, you could try batching the expanded contact requests.
Related
Let's say person B sends a calendar event invite to person A. When we then run the following query for person A, we can see the event in the response with responseStatus.response="notResponded", which is fine:
https://graph.microsoft.com/v1.0/me/events?startDateTime=2023-01-11T23%3A00%3A01.000Z&endDateTime=2023-01-12T23%3A00%3A00.000Z
However, when person A declines the invitation, then the event disappears from the response.
Is there a way to modify the query or use a different endpoint to still have access to the declined events?
I tried to look for the solution in the MS Graph API docs, but couldn't find any hints.
responseStatus property doesn't support filtering but as an alternative you can use extended property PidLidResponseStatus and filter those events with PidLidResponseStatus equals to respDeclined int value 4.
https://graph.microsoft.com/v1.0/me/events?startDateTime=2023-01-11T23%3A00%3A01.000Z&endDateTime=2023-01-12T23%3A00%3A00.000Z&$filter=singleValueExtendedProperties/any(ep:ep/id eq 'Integer {00062002-0000-0000-C000-000000000046} Id 0x8218' and cast(ep/value, Edm.Int32) eq 4)
But if declined event is remove from the calendar then it cannot be listed.
Documentation:
PidLidResponseStatus
Some of the Graph API return a lot of data and require paging. Exists a lastModifiedDateTime property to get only changed rows, such as to make this call that returns users who are modified since a given date?
https://graph.microsoft.com/beta/users?$filter=lastModifiedDateTime gt '2020-01-01T12:00:00Z'
or get the classes that have changed (Educational API)
https://graph.microsoft.com/beta/education/classes?$filter=lastModifiedDateTime gt '2020-01-01T12:00:00Z'
The Property you are trying i.e., 'lastModifiedDateTime' is not part of the MS Graph.
In Ms Graph this is possible with directoryAudits method which contains all information related to changes(logs) in Azure AD.
To Get the last activity in azure you need to use 'activityDateTime' property and to get the user information 'initiatedBy' property.
I would like to query from Microsoft Graph all groups where a specific user is owner.
I tried the following query:
https://graph.microsoft.com/v1.0/groups?$filter=owners/any(owner: owner/id eq '4dc60fe7-8009-4131-a4e9-80dc5e86f98f')
Unfortunately this returns a 400.
Does anyone know the correct OData query? Or is this not even supported by MS Graph?
It's not possible to filter on owners. The documentation states which properties can be $filter'ed.
Look for
Supports $filter
in the description of each property.
You are going to have to read all groups, pull out their owners, and do the filtering client side.
The memberOf endpoint returns all the groups of a given user:
https://graph.microsoft.com/v1.0/users/{ID or email}/memberOf
Will return:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups",
"value": [
{
"id": "XXXX-XXXX-XXXX-XXXX",
"displayName": "The group name",
"...":"...",
}
]
}
It is possible to get all groups with owners using single API call like this:
https://graph.microsoft.com/v1.0/groups?$expand=owners
and then select groups which have current user in owners collection.
You could use List ownedObjects graph API to do that where it gets the list of directory objects that are owned by the user.
But as the question is specifically about getting the list of groups that a user is owner of, you can use the below graph API where it gets the list of directory objects with odata.type as microsoft.graph.group:
GET https://graph.microsoft.com/beta/users/{User Object ID}/ownedObjects/microsoft.graph.group
And if you just want to get the group name and group ID, you can use $select,
GET https://graph.microsoft.com/beta/users/{User Object ID}/ownedObjects/microsoft.graph.group?$select=displayName,id
Expanding properties doesn't seem to work when using Delta queries. It works fine with regular user query.
Is this a limitation in Microsoft Graph API?
var usersInfo = graphServiceClientWithApplicationPermission.Users.Delta().Request().Expand("MemberOf").GetAsync();
// Add inital request users
foreach (var userInfo in usersInfo)
{
// Member info doesn't seem to be expanded even if $expand=MemberOf is sent
if (userInfo.MemberOf == null)
{
userInfo.MemberOf = await applicationPermissionsClient.Users[userInfo.Id].MemberOf.Request().GetAsync();
}
// MemberOf is now populated ??
}
Seems like this is another limitation of the Microsoft Graph and not supported.
Optional query parameters
If a client uses a query parameter, it must be specified in the
initial request. Microsoft Graph automatically encodes the specified
parameter into the nextLink or deltaLink provided in the response. The
calling application only needs to specify their desired query
parameters once upfront. Microsoft Graph adds the specified parameters
automatically for all subsequent requests. For users and groups, t
here are restrictions on using some query parameters:
If a $select query parameter is used, the parameter indicates that the
client prefers to only track changes on the properties or
relationships specified in the $select statement. If a change occurs
to a property that is not selected, the resource for which that
property changed does not appear in the delta response after a
subsequent request. $expand is not supported.
For users and groups beta (preview) APIs, scoping filters allow you to
track changes to one or more specific users or groups by objectId. For
example, the following request:
https://graph.microsoft.com/beta/groups/delta/?$filter= id eq
'477e9fc6-5de7-4406-bb2a-7e5c83c9ae5f' or id eq
'004d6a07-fe70-4b92-add5-e6e37b8acd8e' returns changes for the groups
matching the ids specified in the query filter.
https://developer.microsoft.com/en-us/graph/docs/concepts/delta_query_overview
The documentation clearly states that this endpoint supports $expand to modify the search result:
users/{user-id}/drive/root/search(q='{search-text}')?$expand=permissions
But the request returns the following body in its response:
{
"error": {
"code": "notSupported",
"message": "The request is not supported by the system.",
"innerError": {
"request-id": "30fc9988-6f4f-46ba-a5b4-91b150c4a1a5",
"date": "2017-11-17T02:30:49"
}
}
}
This is also the case for other relationships. Though trying to expand createdByUser results in a BadRequest.
We want to do this request to avoid doing subsequent requests. Because at the moment we use a SharePoint ListItemUniqueId (due to backwards comparability) to find the corresponding DriveItem. Then we want to retrieve the permissions of this DriveItem. But right now we need to do two requests to achieve this.
We also can't use /users/{user-id}/drive/items because it does not support $filter.
Are we misunderstanding the docs or is this an issue on the Microsoft Graph side?
You cannot expand the permissions collection. From the documentation:
The permissions relationship of DriveItem cannot be expanded as part of a call to get DriveItem or a collection of DriveItems. You must access the permissions property directly.
The reason $expand=createdByUser returns a BadRequest is because it is already expanded by default.
Properties that are not supported are in $expand on the /search endpoint are:
children - Since /search returns files, this logically wouldn't make any sense here.
lastModifiedByUser - included by default
content - logically the content of each file wouldn't make sense to be included in a collection of DriveItems
Thumbnails can be expanded however ($expand=thumbnails).