Cannot replace custom parameters from single send email API

SOLVE
dcornelljames
Member

Hello,

 

I have created a custom property called category_total using the portal dashboard.  I am trying to set this value in an email template and send the email using the single send email API as specified in documentation here: 
https://developers.hubspot.com/docs/api/marketing/transactional-emails

i.e. POST to https://api.hubapi.com/marketing/v3/transactional/single-email/send using my API key 

I have tried using the following JSON as specified by other posts I have seen in the forum:

{
     "emailId":38143921416,
     "message":{
          "to":"dcornell@gmail.com"
     },
     "contactProperties":[
          {
                    "name":"firstName",
                    "value":"Bubba"
          }
     ],
     "customProperties":[
          {
               "name":"category_total",
               "value":"4071434"
          }
     ]
}

 When using this format, I get the following error returned from the API:

{
"status": "error",
"message": "Invalid input JSON on line 6, column 26: Cannot deserialize instance of `java.util.LinkedHashMap` out of START_ARRAY token",
"correlationId": "5f0520aa-8c32-4c6e-af04-4c0d8e406570"
}
This error seems to indicate that I should not be using arrays but rather name-value pairs.  If I change the format to:
{"emailId":38143921416,
 "message":{"to":"dcornell@gmail.com"},
 "contactProperties":{"firstName":"Bubba"},
 "customProperties":{"contact.category_total":"999999","category_total":"990990909"}
}

then the message is successfully sent and the contact property is overidden to show a first name of "Bubba".  However, the custom property is not getting set.  

Please advise and thanks in advance. 
0 Upvotes
1 Accepted solution

Accepted Solutions
MichaelC
Solution
Top Contributor
Try to move it to contact properties instead of custom properties area of your code. It looks as if it is a self made contact property. Worth a try.


"contactProperties":
{
"firstName":"Bubba",
"contact.category_total":"4071434"
//Try the different versions of the property names here
}

View solution in original post

7 Replies 7
dennisedson
Community Manager

Hi @dcornelljames ,

Thanks for adding the question!

@RiccardoPisani , @thesnappingdog , @MichaelC  would any of you be able to lend a hand here?

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes
MichaelC
Top Contributor

Im not sure you are naming your custom property correctly, it might be a guess but at least we can do a lookup to confirm if it is or not.

 

Have you checked the property system name in the email? 

Go to your email in the marketing tab > open email in edit mode > click settings > scroll down to plain text and web version > click "customize" button. The name within the brackets {{ }} is the official system name for your property. 

 

Thats my primary guess for now anyway - hope it helps! 

 

MichaelC_0-1607029269088.png

 

dcornelljames
Member

My template is one of the defaults with my custom parameter inline.  This is what the text of the email is using the instructions you have mentioned: 
---------

Hello {{contact.firstname}},

Plain text emails have minimal formatting so your reader can really focus on what you have to say. Introduce yourself and explain why you’re reaching out.

{{contact.category_total}}

Every email should try to lead the reader to some kind of action. Use this space to describe why the reader should want to click on the link below. Put the link on its own line to really draw their eye to it.

Link text

Now it’s time to wrap up your email. Before your signature, thank the recipient for reading. You can also invite them to send this email to any of their colleagues who might be interested.

All the best,

Your full name

Your job title

--------

You will see the custom parameter "contact.category_total" in the middle.  You will also see the standard parameter "contact.firstname" at the top.  When I run with the below JSON, the contact.firstname gets populated with Bubba, but the custom parameter does not.  

{
"emailId":38143921416,
"message":{
"to":"dcornelljames@gmail.com"
},
"contactProperties":
{
"firstName":"Bubba"
 
}
,
"customProperties":
{
"contact.category_total":"4071434"
 
}
 
}
This is a screen grab of the resulting email:

Screen Shot 2020-12-03 at 11.52.52 PM.png
 
 
 
I have tried
"contact.category_total":"9999999"
"contact.category_total":9999999
"category_total":"9999999"
"category_total":9999999
 
None seem to work.  
0 Upvotes
MichaelC
Solution
Top Contributor
Try to move it to contact properties instead of custom properties area of your code. It looks as if it is a self made contact property. Worth a try.


"contactProperties":
{
"firstName":"Bubba",
"contact.category_total":"4071434"
//Try the different versions of the property names here
}

View solution in original post

dcornelljames
Member

That was it.  So I guess there is a difference between a "custom property" and a "self made property" as you call it?  Somewhat confusing but it gets me over this hurdle.  Thanks!

0 Upvotes
MichaelC
Top Contributor

Well I agree that this was confusing and missleading. Maybe @dennisedson can forward the information to someone in charge of API documentation to cleary things for future matter in the documentation. Happy the problem got solved - have a nice weekend @dcornelljames 

dennisedson
Community Manager

Thanks @MichaelC , I alerted the team 😃

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!