nmarus / node-ews

A simple JSON wrapper for the Exchange Web Services (EWS) SOAP API.
MIT License
116 stars 52 forks source link

Can't use operation MoveItem #91

Open chonlanotr opened 6 years ago

chonlanotr commented 6 years ago

I try to use MoveItem operation but system response scheme invalid always. But when i try on EWSEditor. it's fine. `const ewsFunction = 'MoveItem';

// define ews api function args const ewsArgs = { 'ToFolderId':{ 'DistinguishedFolderId' :{ 'attributes':{ 'Id':'drafts' } } }, 'ItemIds' : { 'ItemId': { 'attributes': { 'Id': 'AQAVAHF1ZXJ5YWRAZWdjb2Rldi5sb2NhbABGAAADvnHK/c2MG06yT9KSOaaWcAcABDf6ZzkScEGtNwC/nJsJ0AAAAgEMAAAABDf6ZzkScEGtNwC/nJsJ0AAAAgFoAAAA', 'ChangeKey' : 'CQAAABYAAAAEN/pnORJwQa03AL+cmwnQAAAAAAEQ' } } }
};

// query ews, print resulting JSON to console ews.run(ewsFunction, ewsArgs) .then(result => {

// output for GetItem // console.log('SUBJECT' + JSON.stringify(result.ResponseMessages.GetItemResponseMessage.Items.Message.Subject) + ' BODY ' + JSON.stringify(result.ResponseMessages.GetItemResponseMessage.Items.Message.Body.$value) ); console.log(JSON.stringify(result)); }) .catch(err => { console.log(err.stack); });`

node app.js Error: a:ErrorSchemaValidation: The request failed schema validation: The element 'ToFolderId' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has invalid child element 'DistinguishedFolderId' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'. List of possible elements expected: 'FolderId, DistinguishedFolderId' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. at finish (D:\NodeJS\egcobot\exchangeconn\node_modules\soap\lib\wsdl.js:1518:21) at WSDL.xmlToObject (D:\NodeJS\egcobot\exchangeconn\node_modules\soap\lib\wsdl.js:1501:10) at parseSync (D:\NodeJS\egcobot\exchangeconn\node_modules\soap\lib\client.js:364:23) at D:\NodeJS\egcobot\exchangeconn\node_modules\soap\lib\client.js:357:14 at D:\NodeJS\egcobot\exchangeconn\node_modules\node-ews\lib\auth\ntlm\http.js:48:9 at finalCallback (D:\NodeJS\egcobot\exchangeconn\node_modules\httpreq\lib\httpreq.js:98:7) at IncomingMessage.<anonymous> (D:\NodeJS\egcobot\exchangeconn\node_modules\httpreq\lib\httpreq.js:376:9) at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1064:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)

XML from EWSEditor `<?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">

`
chonlanotr commented 6 years ago

I found same error in issue#18 and I can correct it just add "t:" in leave node. request to closed this issue. const ewsArgs = { 'ToFolderId':{ 't:DistinguishedFolderId': { 'attributes' : {'Id':'drafts'} } }, 'ItemIds' : { 't:ItemId': { 'attributes': { 'Id': 'AQAVAHF1ZXJ5YWRAZWdjb2Rldi5sb2NhbABGAAADvnHK/c2MG06yT9KSOaaWcAcABDf6ZzkScEGtNwC/nJsJ0AAAAgEMAAAABDf6ZzkScEGtNwC/nJsJ0AAAAgFoAAAA', 'ChangeKey' : 'CQAAABYAAAAEN/pnORJwQa03AL+cmwnQAAAAAAEQ' } } } };