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

问题描述 投票:0回答:1

我试图使用ews创建任务但它给出ErrorInvalidIdMalformed错误。

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

email_id = "[email protected]"
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, 

数据= RestoreTASK)

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

outlook exchangewebservices office365api outlook-restapi
1个回答
1
投票

错误告诉你folderId是错误的,你怎么知道它是正确的?你是如何在第一时间检索FolderId的?例如,使用DistinguishedFolderId对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>
© www.soinside.com 2019 - 2024. All rights reserved.