Postmark fails if CC & BCC emails are empty

I’m using Postmark for transactional emails and I wanted to enable the option for my users to CC or BCC emails within my app.

I can’t initialize the api call if the fields are blank.

image

This is the error message I get.

image

If I use placeholders, I can initialize the call, but if my user leaves the CC or BCC fields empty in the app, it’ll fail.

I’ve reached out Postmark and they’ve asked:

“Is there a way in Bubble to remove the Key from the request if there is no value?”

Has anyone encountered this before and found a way around it?

You will need to convert your parameters to a json body and use dynamic formatting of your JSON into your API Call action
For example

{
  "From": "<from>",
  "To": "<to>",
  "Subject": "<subject>",
  "TextBody": "<text_body>",
  "HtmlBody": "<html_body>"<cc><bcc>
}

When you will process to the action, you will check if the cc is empty (cc field’s is empty:format as text … YES will be empty and No will be ,“cc”:“input cc value”
Similar process for bcc

1 Like

Thanks for the reply @Jici.
I’m a complete novice with APIs and html, so forgive my stupidity here.

Was I supposed to include the expression in the action or the workflow?
NB: I had to include “is not empty” at the end of the expression as it was creating an error.

Would I need to create 4 actions?

  1. CC is not empty and BCC is not empty
  2. CC is not empty
  3. BCC is not empty
  4. CC is empty and BCC is empty

For some reason, I can’t duplicate the Postmark action.
I’ve tried copy/paste the action, I tried copying the entire workflow but this ommits the Postmark action.
When I try to create a new action from scratch, the Postmark API is missing.
I’ve no idea what’s going on there.

With regards to the API, when I try to initialize, it’ll throw up an error again if the values are empty.

image

You need to use Body JSON and put what I’ve set in the body part and delete all parameters.
You will not use Only when, you will use just format as text for the CC and BCC

Thanks for your help @Jici.
I thought I was doing that, but like I said before, I’m a complete novice at this, so I’m a little confused.
I’m not sure whether I need to place something in the < html_body > as I’m using the < CC > & < BCC > parameters in the action.

This is what I’ve set in the JSON body of the API call:
NB: I cannot initialize it as it is. I have completely filled out all the parameter fields except “html_body”.

{
    "From": "<SenderEmail>",
    "To": "<TargetEmail>",
    "TemplateAlias": "course-booking",
"TemplateModel": {
    "NumberOfPeople": "<NumberOfPeople>",
    "CourseTitle": "<CourseTitle>",
    "CourseDate": "<CourseDate>",
    "AttendeeNameList": "<AttendeeNameList>",
    "AttendeeEmailList": "<AttendeeEmailList>",
    "AttendeeUSIList": "<AttendeeUSIList>",
    "UserFullName": "<UserFullName>",
    "SubjectTitle": "<SubjectTitle>",
    "CompanyName": "<CompanyName>",
  "HtmlBody": "<html_body>"<cc><bcc>
  }
}

Here’s the action:

Can you share your API connector settings?

NB: I’m using multiple Postmark APIs without issue.
This is the only one using CC & BCC fields

Maybe try using the parameters?

1 Like

Can you share the Body after the Body type “json” ?

I think I found the issue for you. In your screenshot, in your condition, you don’t have the , before “cc”
Probably also missing in BCC

For my Postmark setup, the way I have it is a body response like this:

{
    "From": "<sender>",
    "To": "<recipient>",
    <cc>
    <bcc>
    <replyTo>
    "TemplateId": "XXXX",....

Then for the Body parameters, I have bcc = “Bcc”: “sample@gmail.com” like this:

image

Whenever I call my API calls, I either replace the email if I need to use that field or just pass in a blank space " " as the parameter if I want it to be empty. Let me know if that makes sense to you.

Hi @rod.danan , I’ve tried your method but I’m having the same issues as before when I initialize the call.

    {
    "From": "<SenderEmail>",
    "To": "<TargetEmail>",
    <cc>
    <bcc>
    "TemplateAlias": "XXXXXXX",
"TemplateModel": {
    "NumberOfPeople": "<NumberOfPeople>",
    "CourseTitle": "<CourseTitle>",
    "CourseDate": "<CourseDate>",
    "AttendeeNameList": "<AttendeeNameList>",
    "AttendeeEmailList": "<AttendeeEmailList>",
    "AttendeeUSIList": "<AttendeeUSIList>",
    "UserFullName": "<UserFullName>",
    "SubjectTitle": "<SubjectTitle>",
    "CompanyName": "<CompanyName>"
  }
}

cc = “Cc”: “email@domain.com”
bcc = “Bcc”: “email@domain.com”

Hi

Why not try Rich Postmark Plugin by Vini

1 Like

agsin, your issue is that you have a missing comma before “cc” and “bcc” in value
Or after in the connector in last screenshot

1 Like

I believe it only allows for one Postmark Server.
I’m using multiple in my app to organise the various emails.

From what I can see, only the batch email will allow for 10 variables to be passed to Postmark. The single email doesn’t have any variables. I’ve set all my templates up on Postmark already, so it’d be difficult to change them and my workflow actions.

Are you referring to the value fields ?
The last screenshot was following @rod.danan 's example.

So far I’ve tried the following in the value fields:

cc = “Cc”:“email@domain.com”
bcc = “Bcc”:“email@domain.com”

(comma before)
cc = ,“Cc”:“email@domain.com”
bcc = ,“Bcc”:“email@domain.com”

If I leave the value fields blank with a space " ", the API will initialize but the workflow action doesn’t work.

image

NB: I’ve left a blank space " " in the Yes option of the :formatted as text.

image
image

I’ve also tried using a comma after:
cc = “Cc”:“email@domain.com”,
bcc = “Bcc”:“email@domain.com”,

Yes.
In my example, the comma should be before but in @rod.danan it should be after.

If you get an error message while initializing the API, please send the complete error message you got

Also, in the action, in “yes” put nothing! (no space… just nothing)

I’ve added the comma at the end of the values and removed the spaces in the “Formatting for yes”.

image

cc = “Cc”:“email@domain.com”,
bcc = “Bcc”:“email@domain.com”,

This is the error on the API side

This is the error on the workflow side.
image

And you are using the payload provided by @rod.danan ?