I'm trying to write a calendar sync using the MS Graph API, i.e. I'm trying to sync events in a local DB to one or several newly created M365 calendars via Graph. In order to keep track of the created calendars, I need to store custom metadata with each calendar. It appears that single-value extended property is the way to add my local ID to the created calendar.
Unfortunately I fail to grasp how to do that: the documentation describes a simple enough request to write the data:
{
"singleValueExtendedProperties": [
{
"id":"String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color",
"value":"Green"
}
]
}
But the json references a GUID which, in its documentation, references the Exchange Server Protocols Master Property List but I don't understand how they're all connected with each other: do I need to select an ID from the Exchange Server Protocols Master Property List? Is it possible to create a custom GUID? Do I need to create a schema extension (which doesn't seem to be possible for calendar resource types)?
So, how do I add custom metadata to my calendars?
When you create a custom named property, it must be identified by the extended property type, property set identifier, and a string name.
Extended property identifier (id):
<property_type> <property_set_guid> Name <name_of_custom_property>
Property type specifies the data type of a property value. Common values are String
, Integer
, StringArray
and IntegerArray
.
Property set is a set of attributes, identified by a GUID. Several of the more common property sets are described here. You can use GUID for PS_PUBLIC_STRINGS
({00020329-0000-0000-C000-000000000046}
) property set name.
String name is a name of your custom property.
Example to create an extended property for a calendar.
PATCH https://graph.microsoft.com/v1.0/me/calendars/{calendar-id}
Content-Type: application/json
{
"singleValueExtendedProperties": [
{
"id": "String {00020329-0000-0000-C000-000000000046} Name YourPropertyName",
"value": "PropertyValue" // local ID you want to store
}
]
}
Get property value by using $expand
query with $filter
inside the expand.
GET https://graph.microsoft.com/v1.0/me/calendars/{calendar-id}?$expand=singleValueExtendedProperties($filter=id eq 'String {00020329-0000-0000-C000-000000000046} Name YourPropertyName')
Resources: