nmarus / node-ews

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

The required attribute 'Traversal' is missing. #16

Closed juan-ruiz closed 8 years ago

juan-ruiz commented 8 years ago

Hi there,

First of all, node-ews is amazing, im really looking forward to unleahs its potential :)

Now, im getting the following following error message on my electron app:

"a:ErrorSchemaValidation: The request failed schema validation: The required attribute 'Traversal' is missing."

I understand i have to set the Traversal attribute on the ewsArgs, but im not sure how.

Im trying the following:

var ews = new EWS(username, password, host, options);

// Get Mails
var ewsFunction = 'FindItem';
var ewsArgs = {
  'Traversal' : 'Shallow',
  'ItemShape': {
    'BaseShape':'IdOnly'
  },
  'ParentFolderIds' : {
    'DistinguishedFolderId' : 'deleteditems'
  }
};

before the ews run in an attempt to replicate the following soap call:

<?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">
  <soap:Body>
    <FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
              Traversal="Shallow">
      <ItemShape>
        <t:BaseShape>IdOnly</t:BaseShape>
      </ItemShape>
      <ParentFolderIds>
        <t:DistinguishedFolderId Id="deleteditems"/>
      </ParentFolderIds>
    </FindItem>
  </soap:Body>
</soap:Envelope> 

So, how can i set the Traversal attribute that is right on the findItem tag?

Now, thanks a lot for your help, and for developing this,

kcastrotech commented 8 years ago

Try this:

// Get Mails
var ewsFunction = 'FindItem';
var ewsArgs = {
  attributes:{Traversal:'Shallow'},
  'ItemShape': {
    'BaseShape':'IdOnly'
  },
  'ParentFolderIds' : {
    'DistinguishedFolderId' : 'deleteditems'
  }
};
juan-ruiz commented 8 years ago

Thanks, that worked like a charm!