With Exchange Web Services a calendar event can be created and assigned to a specific category while that same capability is missing from Graph - microsoft-graph-api

I have been using EWS to create appointments in both Exchange on-premise and Exchange online mailboxes that include a category value. I'm trying to migrate to Microsoft Graph since it's the recommended path according to Microsoft https://learn.microsoft.com/en-us/graph/migrate-exchange-web-services-overview
One of the EWS capabilities I can't replicate is creating a calendar event with a category.
The EWS Appointment class supports setting the category for the appointment - https://learn.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.appointment?view=exchange-ews-api
When testing with Graph to create a calendar event, all responses to the posted requests include a null categories array as shown in the documentation - https://learn.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-1.0&tabs=csharp so it would seem that a request can be made with category.
Using the Microsoft Graph explorer to create a calendar event I naively add the categories property as an array and include a known category from the user's mailbox:
{
"subject": "Test",
"isAllDay": true,
"ShowAs":"Free",
"categories": [
{ "displayName":"Red Category", "color": "preset0" },
],
"start": {
"dateTime": "2022-11-08T00:00:00.0000000",
"timeZone": "Eastern Standard Time"
},
"end": {
"dateTime": "2022-11-09T00:00:00.0000000",
"timeZone": "Eastern Standard Time"
}
}
The response is always:
{
"error": {
"code": "UnableToDeserializePostBody",
"message": "were unable to deserialize "
}
}
I have also changed the property to a key:value which gets the same reponse.
{
"subject": "Test",
"isAllDay": true,
"ShowAs":"Free",
"category": "Red Category",
"start": {
"dateTime": "2022-11-08T00:00:00.0000000",
"timeZone": "Eastern Standard Time"
},
"end": {
"dateTime": "2022-11-09T00:00:00.0000000",
"timeZone": "Eastern Standard Time"
}
}
Does the Graph Create Event POST /users/{id | userPrincipalName}/calendars/{id}/events support including a category?

You were so close.
Categories is an array of strings. This will create the appointment with the Personal category, if there is no Personal category one will be created.
{
"subject": "Test",
"isAllDay": true,
"ShowAs": "Free",
"categories": [
"Personal"
],
"start": {
"dateTime": "2022-11-08T00:00:00.0000000",
"timeZone": "Eastern Standard Time"
},
"end": {
"dateTime": "2022-11-09T00:00:00.0000000",
"timeZone": "Eastern Standard Time"
}
}

Related

Controlling internal and external autoreplies

When I set mailboxsettigs|automaticRepliesSetting|status using MSGraph (for a shared mailbox) it seems to only affect the setting for internal recipients and there seems no syntax for dealing with internal/external recipients. What am I missing?
For external recipients you need to also set externalAudience to all.
PATCH /users/{id}/mailboxSettings
"automaticRepliesSetting": {
"status": "scheduled",
"externalAudience": "all",
"scheduledStartDateTime": {
"dateTime": "2023-02-15T02:00:00.0000000",
"timeZone": "UTC"
},
"scheduledEndDateTime": {
"dateTime": "2023-02-16T02:00:00.0000000",
"timeZone": "UTC"
},
"internalReplyMessage": "<html>\n<body>\n<p>I'm out<br>\n</p></body>\n</html>\n",
"externalReplyMessage": "<html>\n<body>\n<p>I'm out<br>\n</p></body>\n</html>\n"
}

Schema Extensions Microsoft Graph API

Env: Developer Account aka using sandbox and through graph explorer.
I am having trouble updating a custom field added through schemaExtensions. Here are the steps:
POST https://graph.microsoft.com/v1.0/schemaExtensions
{
"id": {schemaName},
"description": "Meta data",
"targetTypes": [
"Event"
],
"owner": {app_id},
"properties": [
{
"name": "Pid",
"type": "String"
}
]
}
I get a 201 response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#schemaExtensions/$entity",
"id": "extiv30x2jc_{schemaName}",
"description": "Meta data",
"targetTypes": [
"Event"
],
"status": "InDevelopment",
"owner": {app_id},
"properties": [
{
"name": "Pid",
"type": "String"
}
]
}
I then create a event as below:
POST https://graph.microsoft.com/v1.0/me/events
{
"subject": "My event",
"start": {
"dateTime": "2021-02-25T22:45:11.110Z",
"timeZone": "UTC"
},
"end": {
"dateTime": "2021-02-25T22:45:11.110Z",
"timeZone": "UTC"
}
}
Event is successfully created and I note the id of the event. I then patch the event, since it is not possible to create an instance and update the custom field simultaneously.
PATCH https://graph.microsoft.com/v1.0/me/events/{id}
{
"extiv30x2jc_{schemaName}": {
"Pid": "1"
}
}
For which I get a 200 response like below:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users({graph_explorer_profile_id})/events/$entity"
}
To search for the event to see if the custom field has been updated, i use this:
GET https://graph.microsoft.com/v1.0/me/events/{id}
But I cannot find the custom field Pid. What did I do wrong here?
Regarding
But I cannot find the custom field Pid. What did I do wrong here?
by default schema extensions are not getting returned. Use select parameter to return schema extension along with default event properties:
GET https://graph.microsoft.com/v1.0/me/events/{id}?$select=extiv30x2jc_{schemaName}
Try to call this endpoint:
GET https://graph.microsoft.com/v1.0/me/events/{id}/extensions

Which property is used to determin whether to allow forwarding an event message in graph api?

When I get a Message or Event object, I don't see any property that seems to be related to AllowForward. Tried both v1.0 and beta.
There is no strongly typed property so you need to use the Extended property for this eg to send a Meeting with no forward
{
"subject": "My event",
"start": {
"dateTime": "2020-10-13T04:55:36.463Z",
"timeZone": "UTC"
},
"end": {
"dateTime": "2020-10-20T04:55:36.463Z",
"timeZone": "UTC"
},
"attendees": [
{
"emailAddress": {
"address":"blah#domain.com",
"name": "gs"
},
"type": "required"
}
],
"SingleValueExtendedProperties": [
{
"PropertyId": "Boolean {00020329-0000-0000-C000-000000000046} Name DoNotForward",
"Value": "true"
}
]
}
Then to retrieve that property with an event use
https://graph.microsoft.com/v1.0/me/events?$expand=SingleValueExtendedProperties($filter%20%3D%20(id%20eq%20'Boolean%20%7B00020329-0000-0000-C000-000000000046%7D%20Name%20DoNotForward'))

Microsoft Graph API creating recurring event returns 500

I'm writing an app that synchronizes with Office365's events using the Microsoft Graph API v1.0.
When creating a single event, the event gets created as expected:
Response Status Code: 201 Created
Request URL: https://graph.microsoft.com/v1.0/me/calendars/<myCalendarId>/events
Request Method: POST
Request Payload:
{
"subject": "single event",
"start": {
"dateTime": "2020-02-15T09:00:00",
"timeZone": "Europe/Berlin"
},
"end": {
"dateTime": "2020-02-15T10:00:00",
"timeZone": "Europe/Berlin"
},
"attendees": [],
"type": "singleInstance",
"location": {
"displayName": null
},
"recurrence": null
}
If, however, I send a create request for a recurring event, I get a error response.
Response Status Code: 500 Internal Server Error
Request URL: https://graph.microsoft.com/v1.0/me/calendars/<myCalendarId>/events
Request Method: POST
Request Payload:
{
"subject": "test recurring event",
"start": {
"dateTime": "2020-02-14T09:00:00",
"timeZone": "Europe/Berlin"
},
"end": {
"dateTime": "2020-02-14T10:00:00",
"timeZone": "Europe/Berlin"
},
"attendees": [],
"location": {
"displayName": null
},
"recurrence": {
"pattern": {
"daysOfWeek": [],
"type": "daily"
},
"range": {
"numberOfOccurrences": "2",
"recurrenceTimeZone": "Europe/Berlin",
"startDate": "2020-02-14",
"type": "numbered"
}
}
}
Response Body:
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"request-id": "2d97931c-e08c-45a8-8167-5849df53a694",
"date": "2020-02-14T14:38:28"
}
}
}
I find it strange that the addition of the recurrence settings causes an Internal Server Error.
What can I do to create a recurring event with the API?
If you want to create a recurring event that occurs daily, instead of setting pattern in the following way:
"pattern": {
"daysOfWeek": [],
"type": "daily"
},
Please set pattern this way:
"pattern": {
"type": "daily",
"interval": 1
},
Creating a daily recurrence pattern is described here in the conceptual docs. Within the next day, there will also be a REST example in the reference docs.

MSGraph findMeetingTimes API return 500 Error

I am using the graph API's findmeetingTimes to get free/busy time.
If there is an event set in seconds in the time range within the range specified by the Timeslots parameter,500 error will be returned
For example, if I send following request :
POST https://graph.microsoft.com/v1.0/me/findMeetingTimes
{
"attendees": [],
"timeConstraint": {
"timeslots": [
{
"start": {
"dateTime": "2018-07-19T09:00:00.000Z",
"timeZone": "UTC"
},
"end": {
"dateTime": "2018-07-19T21:00:00.000Z",
"timeZone": "UTC"
}
}
]
},
"meetingDuration": "PT1H"
}
API returns following RESPONSE :
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"request-id": "43a1699f-2241-4c59-8450-826612466f07",
"date": "2018-07-19T02:16:22"
}
}
}
This is my Calencar(Only 1 event on July 19, 2018)
Get https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2018-07-19T00:00:00.000Z&enddatetime=2018-07-19T23:59:59.999Z
・
・
・
"start": {
"dateTime": "2018-07-19T12:00:00.0000000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2018-07-19T12:33:33.0000000",
"timeZone": "UTC"
}
・
・
・
It also happens with outlookAPI
This seems like a bug to me.
Is this a known bug, and are there any plans to fix it?
Is there a known work around?
Try changing the timezone label in the time slot, UTC doesn't seem to work for some reason. At this point it's not clear whether it's a gap in the documentation or an issue with the API itself.
I opened a GitHub Issue to have Microsoft investigate

Resources