You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何按名称检索Exchange日历事件的扩展属性(Graph API)

问题描述

我通过Exchange Web Services(EWS)的UpdateItem SOAP调用给Exchange日历添加了扩展属性(整数类型TTID和字符串类型TTSyncID),SOAP请求代码如下:

<mes:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone">
    <mes:ItemChanges>
       <typ:ItemChange>
          <typ:ItemId Id="%s" ChangeKey="%s" />
          <typ:Updates>
             <typ:SetItemField>
                <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TTID" PropertyType="Integer"/>
                <typ:CalendarItem>
                   <typ:ExtendedProperty>
                      <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TTID" PropertyType="Integer"/>
                      <typ:Value>10</typ:Value>
                   </typ:ExtendedProperty>
                </typ:CalendarItem>
             </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TTSyncID" PropertyType="String"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="%s" PropertyType="String"/>
                     <typ:Value>SomeStringData</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
          </typ:Updates>
       </typ:ItemChange>
    </mes:ItemChanges>
 </mes:UpdateItem>

此前通过EWS的GetItem SOAP请求可以正常获取这些属性:

<ExtendedProperty>
    <ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TTID" PropertyType="Integer"/>
    <Value>10</Value>
</ExtendedProperty>
<ExtendedProperty>
    <ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TTSyncID" PropertyType="String"/>
    <Value>SomeStringData</Value>
</ExtendedProperty>

现在我尝试通过Postman调用MS Graph API,和其他事件属性一起检索这些扩展属性。我认为为了保持向后兼容性,应该使用Outlook扩展属性而非Open extensions(如果这个判断有误请指正)。

但实际调用时遇到问题:singleValueExtendedProperties的扩展要求必须使用MAPIPropertyType和GUID。当我调用:

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

且{{extensionID}}设为TTSyncID或TTID时,会返回错误:

{
  "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'."
  }
}

请问:

  • 我能否获取对应的namespaceGuid来使用?
  • 有没有更简便的方式,直接通过可读名称TTSyncID或TTID来引用这些属性?

解决方案

兼容性判断验证

你的判断是正确的:通过EWS创建的扩展属性属于Outlook传统扩展属性(对应Graph中的singleValueLegacyExtendedProperty或multiValueLegacyExtendedProperty),而Open extensions是Graph API特有的扩展机制,无法兼容EWS创建的属性。

获取namespaceGuid的方法

你不需要额外获取,直接使用PublicStrings属性集对应的固定GUID即可:00020329-0000-0000-C000-000000000046。这个GUID是Exchange中PublicStrings属性集的标准标识,所有通过EWS指定DistinguishedPropertySetId="PublicStrings"创建的属性都属于这个属性集。

正确的Graph API调用格式

你需要按照Graph要求的规范格式构造extensionID,格式为:

[MAPI属性类型] [属性集GUID] Name [属性名称]

针对你的两个属性,正确的ID格式如下:

  1. 整数类型TTID:
    Integer 00020329-0000-0000-C000-000000000046 Name TTID
    
  2. 字符串类型TTSyncID:
    String 00020329-0000-0000-C000-000000000046 Name TTSyncID
    

对应的完整请求URL示例(一次性获取两个属性):

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

能否直接使用可读名称?

不行,Graph API对传统扩展属性的检索必须使用包含MAPI类型、属性集GUID和属性名称的规范ID格式,无法直接通过属性名称进行过滤或引用。如果想简化后续调用,可以将这些规范ID封装到代码的配置项中,避免重复拼接。


内容的提问来源于Stack Exchange,提问作者Jan Doggen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 00:01:07