Skip to main content

SImply put, I am trying to generate proper JSON and pass to a webhook.

 

I have a Code by Zap block:
 

const imageUrls = inputData.imageUrls.split(','); // Splitting the URLs
const imagesArray = imageUrls.map(url => {
return { "url": url.trim() }; // Mapping each URL into an object
});

const outputData = {
"title": inputData.title,
"text": inputData.text,
"images": imagesArray
};

output = { "jsonContent": JSON.stringify(outputData) };

this is working fine, output is correct:

jsonContent
{"title":"Antibes","text":"On
...

 

i have a Webhook by Zap, All things correctly formatted & verified

 

In the Data section, one key is content, which is the output from the Code block above

{{_GEN_1700674589490__jsonContent}}

 

However when I look at the received data on the Webhook, it has escaped quotes:

{
"content": "{\"title\":\"Antibes\",\"text\":\"On
...

 

I have tried every combination I can think of to make this work, any help from this point would be lovely :)

Hi @Augie 

Good question.

To help us have true context, post screenshots with how your Zap webhook step is configured.


ok thanks!


@Augie 

Try using this Zap action: Webhook - Custom Request

That will let you put the JSON in the Body Data.

 


still showing escape codes, am i doing this right?

 

 

here’s what was picked up on the server side:

 

i know i’m close…

 

here’s what was in the JSon content block:

 

last up - here’s the script that generats the json:

const imageUrls = inputData.imageUrls.split(','); // Splitting the URLs
const imagesArray = imageUrls.map(url => {
return { "url": url.trim() }; // Mapping each URL into an object
});

const outputData = {
"title": inputData.title,
"text": inputData.text,
"images": imagesArray
};

output = { "jsonContent": JSON.stringify(outputData) };

 

thanks!!


@Augie 

Looks like you are missing the opening and closing { }

 


thanks - i’m sorry, i don’t follow - where specifically am i missing them?


just for clarity, heres the current steps:
...
javascript:
 

 

method one - custom request:

 

this fails with a JSON error (so I know something’s wrong)

 

method 2: post webhook:

this fails server-side

 

 

so i know i’m… “close” :)


@Augie 

Can you post the API endpoint docs you are referencing to configure this Zap step?