Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS WorkMail: 500 Error #431

Open
GaboDimitrov opened this issue Nov 27, 2023 · 1 comment
Open

AWS WorkMail: 500 Error #431

GaboDimitrov opened this issue Nov 27, 2023 · 1 comment

Comments

@GaboDimitrov
Copy link

I am encountering a 500 Internal Server Error while attempting to retrieve user availability from AWS WorkMail using the GetUserAvailability operation. I have tried two authentication methods—WebCredentials and AssumeImpersonationRole (OAuthCredentials). In both cases, the login is successful, but the subsequent command execution results in a 500 error.

Code Samples:

Web credentials authentication:

const ews = require('ews-javascript-api');

const exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
exch.Credentials = new ews.WebCredentials('user@domain.com', 'PASSWORD');
exch.Url = new ews.Uri('https://ews.mail.eu-west-1.awsapps.com/EWS/Exchange.asmx');

AssumeImpersonationRole (OAuthCredentials) authentication:

const ews = require('ews-javascript-api');
const {
  WorkMailClient,
  AssumeImpersonationRoleCommand,
} = require('@aws-sdk/client-workmail');

const client = new WorkMailClient({ region: 'eu-west-1' });
const params = {
  OrganizationId: 'WORKMAIL-ORGANISATION-ID',
  ImpersonationRoleId: 'IMPERSONATION-ROLE-ID',
};

const command = new AssumeImpersonationRoleCommand(params);
const data = await client.send(command);

const exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
exch.Credentials = new ews.OAuthCredentials(`Bearer ${data.Token}`);
exch.Url = new ews.Uri('https://ews.mail.eu-west-1.awsapps.com/EWS/Exchange.asmx');
exch.ImpersonatedUserId = new ews.ImpersonatedUserId(
  ews.ConnectingIdType.SmtpAddress,
  'user@domain.com',
);

Operation Execution:

const attendee = [new ews.AttendeeInfo('user@domain.com')];
const timeWindow = new ews.TimeWindow(
  ews.DateTime.Now,
  ews.DateTime.Now.AddDays(2),
);

exch.GetUserAvailability(
  attendee,
  timeWindow,
  ews.AvailabilityData.FreeBusyAndSuggestions,
).then(
  function (availabilityResponse) {
    console.log(availabilityResponse);
  },
  function (errors) {
    console.log(errors);
  },
);

Error Received:

SoapFaultDetails {
  message: 'Request failed with status code 500',
  InnerException: null,
  faultCode: null,
  faultString: null,
  faultActor: null,
  responseCode: 127,
  errorCode: 0,
  exceptionType: null,
  lineNumber: 0,
  positionWithinLine: 0,
  errorDetails: DictionaryWithStringKey {
    keys: [],
    keysToObjs: {},
    objects: {},
    keyPicker: [Function (anonymous)]
  },
  HttpStatusCode: undefined
}
@gautamsi
Copy link
Owner

enable debug logging and see if there is any error which is not captured here in SoapFaultDetail. Also have you tried using this credential in EWS Editor to check if there is some other error.
https://github.com/dseph/EwsEditor/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants