MoveItem 无效请求

MoveItem Invalid Request

我正在尝试使用 EWS MoveItem XML 请求删除项目。我将此请求发送到 makeEwsRequestAsync 函数:

function getMoveItemRequest(id, changeKey) {

    var result =
        '<?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:t="https://schemas.microsoft.com/exchange/services/2006/types">' +
        '<soap:Header>' +
        '<RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />' +
        '</soap:Header>' +
        '<soap:Body>' +
        '<MoveItem xmlns="https://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">' +
            '<ToFolderId>' +
                '<t:DistinguishedFolderId Id="deleteditems" />' +
            '</ToFolderId>' +
            '<ItemIds>' +
                '<t:ItemId Id="' + id + '" ChangeKey="' + changeKey + '" />' +
            '</ItemIds>' +
        '</MoveItem>' +
        '</soap:Body>' +
        '</soap:Envelope>';

    return result;
}

我从这样的消息中获取项目 ID:

Office.context.mailbox.item.itemId

我得到这样的 changekey:

var mailbox = Office.context.mailbox;
var soapToGetItemData = getItemDataRequest(mailbox.item.itemId);

    Office.context.mailbox.makeEwsRequestAsync(soapToGetItemData, function(result) {
        var response = $.parseXML(result.value);
        var responseString = result.value;

        // TODO: May want to reconsider the logic for getting the ChangeKey
        var indexOfChangeKey = responseString.indexOf("ChangeKey=\"");
        var substringAfterChangeKey = responseString.substring(indexOfChangeKey + 11);
        var indexOfQuotes = substringAfterChangeKey.indexOf("\"");
        var changeKey = substringAfterChangeKey.substring(0, indexOfQuotes);

这里是 getItemDataRequest 函数:

function getItemDataRequest(itemId) {
    var soapToGetItemData = '<?xml version="1.0" encoding="utf-8"?>' +
        '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
        '               xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"' +
        '               xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
        '               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
        '               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
        '  <soap:Header>' +
        '    <RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />' +
        '  </soap:Header>' +
        '  <soap:Body>' +
        '    <GetItem' +
        '                xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"' +
        '                xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
        '      <ItemShape>' +
        '        <t:BaseShape>IdOnly</t:BaseShape>' +
        '        <t:AdditionalProperties>' +
        '            <t:FieldURI FieldURI="item:Attachments" /> ' +
        '        </t:AdditionalProperties> ' +
        '      </ItemShape>' +
        '      <ItemIds>' +
        '        <t:ItemId Id="' + itemId + '"/>' +
        '      </ItemIds>' +
        '    </GetItem>' +
        '  </soap:Body>' +
        '</soap:Envelope>';
    return soapToGetItemData;
}

然而,我从中收到无效响应(返回的 XML 中包含“请求无效。” .)

知道发生了什么事吗?

谢谢!

需要在请求中使用 http 而不是 https。

function getMoveItemRequest(id, changeKey) {
    var result =
        '<?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:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
        '<soap:Header> ' +
            '<t:RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" /> ' +
        '</soap:Header> ' +
        '<soap:Body> ' +
            '<MoveItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ' +
                'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
                '<ToFolderId> ' +
                    '<t:DistinguishedFolderId Id="deleteditems"/> ' +
                '</ToFolderId> ' +
                '<ItemIds> ' +
                    '<t:ItemId Id="' + id + '" ChangeKey="' + changeKey + '"/> ' +
                '</ItemIds> ' +
            '</MoveItem> ' +
        '</soap:Body> ' +
        '</soap:Envelope> ';

    return result;
}