How to retrieve extended properties of type datetime?

194 Views Asked by At

As a followup to How to retrieve extended properties for calendar event (by name)?: I can retrieve integer and string values with the singleValueExtendedProperties expansion, but how to retrieve dateTime values?

This fails ({{ }} are Postman variables):

https://graph.microsoft.com/v1.0/users/{{UserID}}/calendar/events/{{TTSyncedEventID}}?$expand=singleValueExtendedProperties($filter=id eq 'dateTime {00020329-0000-0000-C000-000000000046} Name TTSyncTime')

...with a not very helpful response:

{
  "error": {
     "code": "ErrorInvalidProperty",
     "message": "PropertyId values may only be in one of the following formats: 'MapiPropertyType namespaceGuid Name propertyName', 'MapiPropertyType namespaceGuid Id propertyId' or 'MapiPropertyType propertyTag'."
  }
}

I have tried several variations on date(Time) but without success...

2

There are 2 best solutions below

4
On

As per the doc ,there is already start/dateTime property outside of singleValueExtendedProperties , so you can directly call the API - https://graph.microsoft.com/v1.0/me/calendar/events?$filter=start/dateTime eq '2022-12-28T12:30:00Z' enter image description here

0
On

Found it thanks to Vicky's comments.
These datetime properties were created with EWS in the same manner as the integer/string values described in the earlier SO question.
That code contains PropertyType="SystemTime", and that is exactly what I need to use:

<typ:SetItemField>
   <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TTSyncTime" PropertyType="SystemTime"/>
   <typ:CalendarItem>
      <typ:ExtendedProperty>
         <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TTSyncTime" PropertyType="SystemTime"/>
         <typ:Value>UTCString</typ:Value>
      </typ:ExtendedProperty>
   </typ:CalendarItem>
</typ:SetItemField>

So the proper query becomes:

https://graph.microsoft.com/v1.0/users/{{UserID}}/calendar/events/{{TTSyncedEventID}}?$expand=singleValueExtendedProperties($filter=id eq 'SystemTime {{PS_PUBLIC_STRINGS_NameSpace}} Name TTSyncTime')

({{ }} are Postman variables)