MS Graph API - how to retrieve declined events? - microsoft-graph-api

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

Related

MS Graph: Get all users by manager id

I'm trying to gather all users with a given manager's id.
It seems that MS graph has a bug here.
My query:
https://graph.microsoft.com/v1.0/users?$filter=manager/id eq '0f3b8a2f-8bec-4694-8021-dbfc55eed287'
I expect this query to return all the users that belong to the manager with the given id.
However, this query returns the manager and not the users. But I clearly filter the id of the manager related property and not the user's id.
There's an API specifically for this, List directReports.
You can get the users assigned to the manager with id 0f3b8a2f-8bec-4694-8021-dbfc55eed287 like:
GET /users/0f3b8a2f-8bec-4694-8021-dbfc55eed287/directReports
Another way would be
GET /users/0f3b8a2f-8bec-4694-8021-dbfa55eed297?$expand=directReports

How to retrieve the events from Calendar when using the $expend parameter in MS Graph API?

I want to get the events in the a specific user's calendar by using the MS Graph API. I have used the API GET https://graph.microsoft.com/v1.0/me/calendars?$expend=events, However, it does not work. The events collection is null. And there are some event in my calendar.
Anyone can help?
According to your description, I assume you want to list the events in a specific user's calendar.
Based on my test, we can use the following code:
public async Task<ICollection<Event>> EventsAsync(string calendarId)
{
var events = await _serviceClient.Me.Calendars[calendarId].Events.Request().GetAsync();
return events.CurrentPage;
}
As the event is a relationships of the calendar, so the event will be null when we request a calendar. However, according to this document:
Note: Not all relationships and resources support the $expand query parameter. For example, you can expand the directReports, manager, and memberOf relationships on a user, but you cannot expand its events, messages, or photo relationships. Not all resources or relationships support using $select on expanded items
So we need request the GET /users/{id | userPrincipalName}/calendars/{id}/eventsendpoint

Get extended properties in office 365 graph delta API

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.

How to get the end screen element with an end_screen_element_id from Youtube API

With a channel reporting job, we can get the end_screen_element_ids for a given video. These IDs look like GUIDs.
The question is : How do we query the Youtube API to get what video/channel/... these end_screen_element_ids points to ?
Thanks!
You may use the reportTypes.list method. This returns a list of report types that the channel or content owner can retrieve. Each item in the list contains an id property, which identifies the report's ID, and you need this value to schedule a reporting job.

Microsoft graph API: finding event by iCalUid

I would like to decline one instance of recurring meeting. I only have masterSerieId, iCalId, time of that instance.
Do you know how I could cancel that instance?
Do I have to query using masterId and time of the instance to find event id or there is a way I would just find eventId using iCalId?
You can use OData query options to filter on just the event that has that particular iCalUId.
For instance:
GET https://graph.microsoft.com/v1.0/me/events?$filter=iCalUId eq '<your iCalUId>'
Sadly the calendar view endpoint does not include events which are part of an event series if you match against a given iCalUId.
So if an event has a seriesMasterId which is not null, you wont find it by filtering for the iCalUId.

Resources