EWS 无法使用 XML 更新 Exchange 联系人 Phone 号码
EWS Cannot Update Exchange Contact Phone Numbers with XML
我想使用 Exchange Web 服务 SOAP API 和 XML 更新我的交换联系人。
我已经(煞费苦心地)想出了如何更新我想要的所有属性,除了 Phone 数字。
我遵循了用于更新 EmailAddresses 的模式(因为它们都是索引字段)。这是我的 XML 请求的示例:
<t:SetItemField>
<t:IndexedFieldURI FieldURI="contacts:PhoneNumber" FieldIndex="BusinessPhone"/>
<Contact xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
<PhoneNumbers>
<Entry key="BusinessPhone">888-777-6666</Entry>
</PhoneNumbers>
</Contact>
</t:SetItemField>
这是我从 Exchange 收到的错误消息:
An internal server error occurred. The operation failed., Key
'PhoneNumbers' not found for type
'Microsoft.Exchange.Services.Core.Types.ContactItemType'
鉴于此操作的 XML 大部分未记录,我怀疑我错误地为 Phone 数字格式化了 XML。
对于使用 EWS Managed API 2.0 的任何人,您能否执行此操作并跟踪 XML 输出以便我了解它是如何正确完成的?
非常感谢提供解决方案的任何其他信息!
谢谢
Seeing as the XML for this operation is largely undocumented, I am under the suspicion I am formatting the XML for the PhoneNumber incorrectly.
MSDN https://msdn.microsoft.com/en-us/library/office/aa580675(v=exchg.150).aspx also the protocol documentation has pretty comprehensive coverage https://msdn.microsoft.com/en-us/library/cc425499(v=exchg.80).aspx
上有所有 XML 元素的完整文档
根据您的要求,我可以重现您要修复的错误,您需要做的就是将密钥中的 K 大写,例如
<Entry key="BusinessPhone">888-777-6666</Entry>
至
<Entry Key="BusinessPhone">888-777-6666</Entry>
SOAP(或者至少它在 EWS 中的实现方式)在元素的大小写和顺序方面是特定的。这是对我有用的修改后的 SOAP
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
<m:ItemChanges>
<t:ItemChange>
<t:ItemId Id="A...A=" ChangeKey="EQA....Z" />
<t:Updates>
<t:SetItemField>
<t:IndexedFieldURI FieldURI="contacts:PhoneNumber" FieldIndex="BusinessPhone"/>
<Contact xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
<PhoneNumbers>
<Entry Key="BusinessPhone">888-777-6666</Entry>
</PhoneNumbers>
</Contact>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</m:ItemChanges>
</m:UpdateItem>
</soap:Body>
</soap:Envelope>
我想使用 Exchange Web 服务 SOAP API 和 XML 更新我的交换联系人。 我已经(煞费苦心地)想出了如何更新我想要的所有属性,除了 Phone 数字。
我遵循了用于更新 EmailAddresses 的模式(因为它们都是索引字段)。这是我的 XML 请求的示例:
<t:SetItemField>
<t:IndexedFieldURI FieldURI="contacts:PhoneNumber" FieldIndex="BusinessPhone"/>
<Contact xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
<PhoneNumbers>
<Entry key="BusinessPhone">888-777-6666</Entry>
</PhoneNumbers>
</Contact>
</t:SetItemField>
这是我从 Exchange 收到的错误消息:
An internal server error occurred. The operation failed., Key 'PhoneNumbers' not found for type 'Microsoft.Exchange.Services.Core.Types.ContactItemType'
鉴于此操作的 XML 大部分未记录,我怀疑我错误地为 Phone 数字格式化了 XML。
对于使用 EWS Managed API 2.0 的任何人,您能否执行此操作并跟踪 XML 输出以便我了解它是如何正确完成的?
非常感谢提供解决方案的任何其他信息!
谢谢
Seeing as the XML for this operation is largely undocumented, I am under the suspicion I am formatting the XML for the PhoneNumber incorrectly.
MSDN https://msdn.microsoft.com/en-us/library/office/aa580675(v=exchg.150).aspx also the protocol documentation has pretty comprehensive coverage https://msdn.microsoft.com/en-us/library/cc425499(v=exchg.80).aspx
上有所有 XML 元素的完整文档根据您的要求,我可以重现您要修复的错误,您需要做的就是将密钥中的 K 大写,例如
<Entry key="BusinessPhone">888-777-6666</Entry>
至
<Entry Key="BusinessPhone">888-777-6666</Entry>
SOAP(或者至少它在 EWS 中的实现方式)在元素的大小写和顺序方面是特定的。这是对我有用的修改后的 SOAP
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
<m:ItemChanges>
<t:ItemChange>
<t:ItemId Id="A...A=" ChangeKey="EQA....Z" />
<t:Updates>
<t:SetItemField>
<t:IndexedFieldURI FieldURI="contacts:PhoneNumber" FieldIndex="BusinessPhone"/>
<Contact xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
<PhoneNumbers>
<Entry Key="BusinessPhone">888-777-6666</Entry>
</PhoneNumbers>
</Contact>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</m:ItemChanges>
</m:UpdateItem>
</soap:Body>
</soap:Envelope>