无法在联机交换中使用 ews 在任务文件夹中创建任务



我正在尝试使用 ews 创建任务,但它给出了错误无效 Id格式错误的错误。

我已经尝试使用已知文件夹名称和任务文件夹 ID 但无法创建任务

email_id = "xyz@pqr.onmicrosoft.com"
folder_id = "tasks"
# or folder_id="id of some task folder"
RestoreTASK = b'''<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
    <t:RequestServerVersion Version="Exchange2007_SP1" />
    <t:ExchangeImpersonation>
      <t:ConnectingSID>
        %s
      </t:ConnectingSID>
    </t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<CreateItem
    xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
    MessageDisposition="SaveOnly">
    <SavedItemFolderId>
        <t:FolderId Id="%s"/>
    </SavedItemFolderId>
    <Items>
        <t:Task>
            <t:Subject>My task EWS</t:Subject>
            <t:DueDate>2006-10-26T21:32:52</t:DueDate>
            <t:Status>NotStarted</t:Status>
        </t:Task>
    </Items>
  </CreateItem>
</soap:Body>
</soap:Envelope>''' % (email_id, folder_id)
ews_api_url = 'https://outlook.office365.com/EWS/Exchange.asmx'
response = requests.post(url=ews_api_url, headers = headers, 

data=RestoreTASK(

因此,我需要在我的 soap 请求中进行更改,因为我手动指定的文件夹 ID 是正确的。请帮忙。

错误告诉您文件夹 ID 是错误的,那么您如何知道它的正确性?您最初是如何检索文件夹ID的?例如,使用DistinctedFolderId对您的XML进行简单测试可以正常工作

<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
    <t:RequestServerVersion Version="Exchange2007_SP1" />
 </soap:Header>
<soap:Body>
<CreateItem
    xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
    MessageDisposition="SaveOnly">
    <SavedItemFolderId>
        <t:DistinguishedFolderId Id="tasks"/>
    </SavedItemFolderId>
    <Items>
        <t:Task>
            <t:Subject>My task EWS</t:Subject>
            <t:DueDate>2006-10-26T21:32:52</t:DueDate>
            <t:Status>NotStarted</t:Status>
        </t:Task>
    </Items>
  </CreateItem>
</soap:Body>
</soap:Envelope>

最新更新