Skip to content

sendMail always throws an error #156

@domihagen

Description

@domihagen

Bug Report

Prerequisites

  • Can you reproduce the problem?
  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?

Version

1.5.2

Description

When i am sending Mails via the sendMail-Route it always throws an error "invalid json response body at https://graph.microsoft.com/v1.0/users/MY_USER_ID/sendMail reason: Unexpected end of JSON input"

Code-Example

const mailMessage = {
  message: {
    subject: 'My Mail-Subject',
    body: {
      contentType: 'Text',
      content: 'My Mail-Content only Text.'
    },
    from: {
      emailAddress: {
        address: 'from@domain.com'
      }
    },
    toRecipients: [
      {
        emailAddress: {
          address: 'to@domain.com'
        }
      }
    ]
  },
  saveToSentItems: false
}

try {
  await client.api(`/users/${userId}/sendMail`).post(mailMessage)
} catch (e) {
  console.error(JSON.stringify(e, undefined, 4))
}

Console Errors:

 {
    "statusCode": 202,
    "code": "FetchError",
    "message": "invalid json response body at https://graph.microsoft.com/v1.0/users/MY_USER_ID/sendMail reason: Unexpected end of JSON input",
    "requestId": null,
    "date": "2019-03-27T15:12:20.964Z",
    "body": "FetchError: invalid json response body at https://graph.microsoft.com/v1.0/users/MY_USER_ID/sendMail reason: Unexpected end of JSON input"
}

Steps to Reproduce

  1. Sending POST-Request via client to sendMail-Route
  2. When the response come back, it falls into the catch-block with statusCode 202 and the message from above

Expected behavior:
Finish without throwing an error.

Actual behavior:
Throwing an error, but mails was sent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions