APIs & Integrations

EPlaza
Member

Cannot send Array of Objects as a value for a custom event property

hello, I'm trying to send an array of objects as a value for an event property but I keep getting an error 

"message": "Invalid input JSON on line 1, column 120: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)",

this is what i am sending

{
properties:{
checkout_id: 'checkoutid',
total: 129990,
products: [
 {
  value1: 1,
  value2: "value2",
  price: 0,
 },
 {
  value1: 1389368,
  value2: "value2",
  price: 40000,
 },
 {
  value1: 1389369,
  value2: "value2"
  price: 40000,
 },
 {
  value1: 1389375,
  value2: "value2",
  price: 0,
 },
 {
  value1: 1389381,
  value2: "value2",
  price: 49990,
  }
 ],
email: "random.email@gmail.com"
},
eventName: " pe21569360_order_completed"
email: "random.email@gmail.com"
}
0 Upvotes
2 Replies 2
miljkovicmisa
Top Contributor | Gold Partner
Top Contributor | Gold Partner

Cannot send Array of Objects as a value for a custom event property

Hello @EPlaza , hi @Jaycee_Lewis !

Seems like the json object is not formatted properly, try to stick with the double quotes arount keys and values (is strings) and pay attention to your commas.

Here is the corrected partial version of your object as it should be formatted:

{
	"properties": {
		"checkout_id": 12,
		"total": 129990,
		"products": [{
				"value1": 1,
				"value2": "value2",
				"price": 0
			},
			{
				"value1": 1389368,
				"value2": "value2",
				"price": 40000
			}
		],
		"email": "random.email@gmail.com"
	},
	"eventName": " pe21569360_order_completed",
	"email": "random.email@gmail.com"
}


Hope this helps you resolve your issue, also a helpful tool in those situations is a json formatter, because it helps you with debugging the json object. I won't suggest one here but if you do search the google you should find plenty of those.

If my answer was helpful please mark it as a solution.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Cannot send Array of Objects as a value for a custom event property

Hi, @EPlaza 👋 Thanks for reaching out and including those details. Hey, @Teun @miljkovicmisa, do you have any experience or troubleshooting tips you can share here? Thank you for taking a look! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes