Search code examples
javascriptexchangewebservicesews-javascript-api

Error updating an exchange meeting using the ews-javascript-api


I'm using the ews-javascript-api to update an appointment (meeting) in exchange. I am getting an error that says:

The request failed schema validation: The \'SuppressReadReceipts\' attribute is not declared.

I am unable to find anything in documentation that shows me how to do this.

I looked online and wasn't able to find anything helpful.

    async updateExchangeItem(_json: any): Promise<any>{
        EwsLogging.DebugLogEnabled = false;
        service.ImpersonatedUserId = new ews.ImpersonatedUserId(ews.ConnectingIdType.SmtpAddress, "myconferenceroom@me.com");
        var id = 'abcdefg';
        var mailbox = new Mailbox("myconferenceroom@me.com");
        var primaryCal = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, mailbox), new PropertySet());

        var meeting = await Appointment.Bind(service, new ItemId(id), ).then((response) =>{
            if (response) {
                response.Subject = 'my subject';
                response.Start = new ews.DateTime('08/28/2019 8:00 am');
                response.End = new ews.DateTime('08/28/2019 9:00 am');

                response.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy).then(response =>{
                    console.log("worked");
                    return("worked");
                }).catch((error) => {
                    console.log(error);
                });
            }
        });
        return("done");
    }

Here is the complete error message:

SoapFaultDetails {
  message: 'The request failed schema validation.',
  InnerException: null,
  faultCode: 'a:ErrorSchemaValidation',
  faultString:
   { 'xml:lang': 'en-US',
     faultstring:
      'The request failed schema validation: The \'SuppressReadReceipts\' attribute is not declared.' },
  faultActor: null,
  responseCode: 355,
  errorCode: 0,
  exceptionType: null,
  lineNumber: 1,
  positionWithinLine: 541,
  errorDetails:
   DictionaryWithStringKey {
     keys: [ 'Violation' ],
     keysToObjs: { Violation: 'Violation' },
     objects:
      { Violation: 'The \'SuppressReadReceipts\' attribute is not declared.' },
     keyPicker: [Function] },
  HttpStatusCode: 500 }

Solution

  • It looks like a bug in the source eg have a look at

    https://github.com/gautamsi/ews-javascript-api/blob/master/src/js/Core/Requests/UpdateItemRequest.ts

    specifically

        if (hasValue(this.SuppressReadReceipts)) {
            writer.WriteAttributeValue(XmlAttributeNames.SuppressReadReceipts, true);
        }
    

    This is an optional value that would only be valid when updating items and is false by default. If you have a look at the original source https://github.com/OfficeDev/ews-managed-api/blob/master/Core/Requests/UpdateItemRequest.cs . What you should be doing is after checking there is a value only set the attribute if that value is true (which is what the original does) rather then then setting if there is any value to true.