Mailersend API weird error

Hi Everyone,

i’m having a very weird error when trying to use the @MailerSend API.
i’ve setup my API Connector and call accordingly to this setup : Using MailerSend for transactional emails - #2 by MailerSend

If i use this payload :
{ "from": { "email": "", "name": "Hyperplugs" }, "to": [{ "email": "", "name": "Guillaume Maison" }], "subject": "[Hyperplugs] a New Request has been added", "variables": [{ "email": "", "substitutions": [{ "var": "user.firstname", "value": "Guillaume" }, { "var": "", "value": "" }, { "var": "", "value": "Hyperplugs" }, { "var": "support_email", "value": "" }, { "var": "user.profile", "value": "" }] }], "template_id": "my_template_id" }
to initialize the call, everything runs fine and i receive the email.

But if i use the API call in a workflow (a scheduled backendworkflow), i receive an error message as a response :
422 Unprocessable Entity "{\""message\"":\""The to field is required. (and 5 more errors)\"",\""errors\"":{\""to\"":[\""The to field is required.\""],\""\"":[\""The field is required.\""],\""subject\"":[\""The subject field is required.\""],\""text\"":[\""You must provide one of html, text or template_id.\""],\""html\"":[\""You must provide one of html, text or template_id.\""],\""template_id\"":[\""You must provide one of html, text or template_id.\""]}}"

and people at @MailerSend tell me that i send an empty body (ie the payload above isn’t sent).

It seems that if the call is triggered by Initializing it, it works, but if trigger from a Workflow, it doesn’t send the JSON body …

Does anyone has already had that same problem ?

Thanks for any hint !

Hey @gmaison,

It looks like the 422 error it’s producing is because you’re not sending the required fields Mailersend’s it’s looking for. For example, the to email, from email, subject, textBody, htmlBody, and template id

I would recommend revisiting the Mailersend API docs

That’s my problem : the payload is correctly configured on Bubble side but it seems that it’s lost at a moment between me calling the API Call from the workflow and Mailersend.

But it’s not lost when API Call is done for Initializing it…

Can you screenshot what your API call looks like?

Do you include:
Content-Type: application/json in the header?


And the complete API Call :

You may notice that i’m sending to two recipients, so i have two variables (one for each email).

When clicking on Reinitialize call, @MailerSend receives the body and i receive the both emails. I can see the call, queue and so on in the Activity menu on Mailersend.

When using this call from a workflow, with the very same payload, Mailersend receives an empty body…

i ended up getting it to work…
i used the “bulk email” API and built the complete payload in a backend workflow action …
Meaning no parameters to the API call except for the entire payload