I have a three step zap for updating a client in our CRM, triggered if they open an email from a 3rd party application. I’ve successfully created the trigger (1) that finds the subscriber from the CRM (2) and returns an object, structured as following (omitting non-necessary data):
{
"data": {
"type": "prospect",
"id": 1436,
"attributes": {
"tags": :
"California","C-Level","AZ","CIO","PST"
]
}
}
}
The 3rd step asks the user for a New Tag to add to “tags”, whereby I need to append the New Tag to the existing list of tags.
I am successful in posting (patch in my case) to the API, but my data is malformed and ends up being one long string as a tag (literally, the tag at the CRM is “California, C-Level, AZ, CIO, PST, TestTag” instead of individual tags). Following is my current code…
const newTags = bundle.inputData.tags + ',' + bundle.inputData.new_tag;
const options = {
url: `https://api.outreach.io/api/v2/prospects/${bundle.inputData.id}`,
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${bundle.authData.access_token}`
},
params: {
},
body:{
"data": {
"type": "prospect",
"id": bundle.inputData.id,
"attributes": {
"tags": newTags]
}
}
}
}
Please help me with how I can append .new_tag to the existing .tags list and how it should look in the body.
Much appreciated!