gautamsi / ews-javascript-api

EWS API for TypeScript/JavaScript - ported from OfficeDev/ews-managed-api - node, cordova, meteor, Ionic, Electron, Outlook Add-Ins
MIT License
282 stars 73 forks source link

"The request is invalid" error if ExchangeVersion is set to V2018_01_08 #441

Open bladerunner2020 opened 3 months ago

bladerunner2020 commented 3 months ago

I am not sure if it is issue of ews-javascript-api or ews itself. The customer has Exchange2019 and we tried to set exchange version to V2018_01_08. We got error this:

  Body: {
    __prefix: 's',
    Fault: {
      __prefix: 's',
      faultcode: 'a:ErrorInvalidRequest',
      faultstring: { 'xml:lang': 'ru-RU', faultstring: 'The request is invalid.' },
      detail: {
        ResponseCode: 'ErrorInvalidRequest',
        Message: 'The request is invalid.'
      }
    }
  }

The soap request was:

  <soap:Header>
    <t:RequestServerVersion Version="V2018_01_08"></t:RequestServerVersion>
  </soap:Header>
  <soap:Body>
    <m:FindItem Traversal="Shallow">
      <m:ItemShape>
        <t:BaseShape>IdOnly</t:BaseShape>
        <t:AdditionalProperties>
          <t:FieldURI FieldURI="calendar:AppointmentState"></t:FieldURI>
        </t:AdditionalProperties>
      </m:ItemShape>
      <m:CalendarView MaxEntriesReturned="1000" StartDate="2024-06-16T21:00:00.000Z"
        EndDate="2024-06-26T21:00:00.000Z"></m:CalendarView>
      <m:ParentFolderIds>
        <t:DistinguishedFolderId Id="calendar">
          <t:Mailbox>
            <t:EmailAddress>some-valid@email.com</t:EmailAddress>
          </t:Mailbox>
        </t:DistinguishedFolderId>
      </m:ParentFolderIds>
    </m:FindItem>
  </soap:Body>
</soap:Envelope>

We found out that everything works fine if we set ExchangeVersion to Exchange2016. I found a discussion on GitHub where there discussed a similar issue: https://github.com/ecederstrand/exchangelib/issues/927

ews-javascript-api - v0.12.0

gautamsi commented 3 months ago

this probably is the problem with exchange, if you are able to work with 2016, it should be used. any higher version number in the EWS does not provide any new feature as Microsoft has stopped working on them presumably.

bladerunner2020 commented 2 months ago

this probably is the problem with exchange, if you are able to work with 2016, it should be used. any higher version number in the EWS does not provide any new feature as Microsoft has stopped working on them presumably.

I agree. I added this comment just to make this issue and solution findable here )) Maybe it would be a good idea to put this into documentation as it's not obvious at all...