node-ews
node-ews copied to clipboard
MoveItem xml request is missing namespaces in subelements
The MoveItem operation is missing crucial namespaces for it to work (at least with Exchange 2013). Fails with "{ "ResponseCode": "ErrorInvalidIdMalformed", "Message": "Id is malformed." }". Using latest release.
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<MoveItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<ToFolderId>
<FolderId Id="AQMkADB..." ChangeKey="AQAAA..." />
</ToFolderId>
<ItemIds>
<ItemId Id="AQMkAD..." ChangeKey="CQAAA..." />
</ItemIds>
</MoveItem>
</soap:Body>
</soap:Envelope>
Manually adding namespaces to args fixes this:
const ewsArgs = {
'tns:ToFolderId': {
't:FolderId': {
attributes: {
Id: folderId,
ChangeKey: folderChangeKey
}
}
},
'tns:ItemIds': {
't:ItemId': {
attributes: {
Id: messageId,
ChangeKey: changeKey
}
}
}
};