Message is empty error on Outlook Node.js sendMail API request on pipedream

I am sending this node.js request through Pipedream:

   async(event, steps, auths) => {
      return await require("@pipedreamhq/platform").axios(this, {
        "url": `https://graph.microsoft.com/v1.0/me/sendMail`,
        "headers": {
          "Authorization": `Bearer ${auths.microsoft_outlook.oauth_access_token}`,
          "Content-Type": 'application/json'
        },
        "method": 'POST',
        "message": {
          "subject": 'Hey there, your whatbuylists product details are attached',
          "body": `Thank you for your purchase of this whatbuylists product list. The details of the list are available here: ${steps.get_product.$return_value.metadata.successURL}`,
          "toRecipients": `${steps.trigger.event.data.object.customer_details.email}`
          }
        }
      
      )
      }

And getting this error. How can I resolve it?:

{
  "error": {
    "code": "ErrorInvalidParameter",
    "message": "The value of the parameter 'Message' is empty."
  }
}
at null.createError (/tmp/ee/node_modules/@pipedreamhq/platform/node_modules/axios/lib/core/createError.js:16:15)
at null.settle (/tmp/ee/node_modules/@pipedreamhq/platform/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/tmp/ee/node_modules/@pipedreamhq/platform/node_modules/axios/lib/adapters/http.js:236:11)
at IncomingMessage.emit (events.js:387:35)
at null.endReadableNT (internal/streams/readable.js:1317:12)
at process.processTicksAndRejections (internal/process/task_queues.js:82:21)

How can I resolve this issue? I am new to coding and trying to automate a workflow in pipedream.

@whatbuylists when you send an HTTP POST request with axios, the body of the request must be included in a data property. Try this:

return await require("@pipedreamhq/platform").axios(this, {
  "url": `https://graph.microsoft.com/v1.0/me/sendMail`,
  "headers": {
    "Authorization": `Bearer ${auths.microsoft_outlook.oauth_access_token}`,
    "Content-Type": 'application/json'
  },
  "method": 'POST',
  data: {
    "message": {
      "subject": 'Hey there, your whatbuylists product details are attached',
      "body": `Thank you for your purchase of this whatbuylists product list. The details of the list are available here: ${steps.get_product.$return_value.metadata.successURL}`,
      "toRecipients": `${steps.trigger.event.data.object.customer_details.email}`
    }
  }
)}

You can read more in this example or in the axios docs.

@dylan
Thanks for the speedy response. The error is gone but I see a new one now:

@whatbuylists this is also an error returned from the Outlook API. It looks like it doesn’t like one of the characters in the body, or for whatever reason it’s not validating the text when you send it to the API.

This is an issue with the Outlook API, so I’d recommend reaching out on their support channels / forum with the error and the request ID and see if they can tell you more information on the error.

You can also try just sending a message with the body “test” to see if that works. If it does, you can try to narrow down specifically what part of the body is failing validation.

Yeah figured this out:

async(event, steps, auths) => {
	return await require("@pipedreamhq/platform").axios(this, {
  url: `https://graph.microsoft.com/v1.0/me/sendMail`,
  headers: {
    "Authorization": `Bearer ${auths.microsoft_outlook.oauth_access_token}`,
    "Content-Type": 'application/json'
  },
  method: 'POST',
  data: {
    message: {
      subject: 'Hey there, your whatbuylists product details are attached',
      "body": {
          "content": `Thank you for your purchase of this whatbuylists product list. The details of the list are available here: ${steps.get_product.$return_value.metadata.successURL}`,
          "contentType": "text"
      },
      toRecipients: [
        {
          "emailAddress": {
            "address": `${steps.trigger.event.data.object.customer_details.email}`
          }
        }
      ]
  }
}
}
)
}

Just noobie mistakes from a no-coder. Would be great if you could add a form for basic send/receive mail to the Outlook integration. Thanks!