Forem

whatbuylists
whatbuylists

Posted on

2 2 1

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}`
          }
        }

      )
      }
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (1)

Collapse
 
sergeewong82 profile image
Serge E Wong •

Hi @whatbuylists,

That's exciting that you are trying to automate stuff via Pipedream!

I know what's going on here.

See, you are using a library called axios to send your request, specifically, you are using a version of axios customized for the Pipedream platform.

So, in this case, axios expects you specify the data to be send with your POST request in an axios configuration parameter named data:

This means that instead of sending the message object as part of axios configuration, you need to wrap it arround data

Instead of:

        "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}`
          }
Enter fullscreen mode Exit fullscreen mode

try:

      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:",
          },          
        toRecipients: recipientArray //you need an array of emails here
        },
      }
Enter fullscreen mode Exit fullscreen mode

where

const recipientArray = ["some@email.pro","someother@email.pro"].map(email => ({ emailAddress: { address: email } }));
Enter fullscreen mode Exit fullscreen mode

by the way, you probably noted the the structure I used in the message object, is different. this is because Microsoft Outlook for sending an email is different than you specified. Please consult the API documentation for complete structure.

finally, at the moment Pipedream also has an Microsoft Outlook "SendMail" nocode component, so you technically don't have to write code just to send an email via this application if you don't need code level control.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

đź‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay