ews-javascript-api
ews-javascript-api copied to clipboard
AWS WorkMail: 500 Error
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('[email protected]', '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,
'[email protected]',
);
Operation Execution:
const attendee = [new ews.AttendeeInfo('[email protected]')];
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
}
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