Take JSON Array from webhook trigger and send as html by email

So I am sending the results of a web scrape via a JSON body with and array of the results. I would like to separate the arrays into HTML and send that via email. This is what I have so far;


I am adding the HTML as part of the concantanate and then adding the whole lot to a list stored in the run.

When I test it the flow works, but when I call it live, the list is outputting as empty. Is there a better way to do this and if this is the right way, why is it not working on a live run?

Thanks in advance for any help.

This is the webhook being received.

{
  "body": {
    "object1": {
      "url": "https://www.linkedin.com/company/york-and-scarborough-teaching-hospitals-nhs-foundation-trust/",
      "post": "Midwifery on the North Yorkshire coast!Come and join our friendly team on the coast! We are looking for Band 6 NMC Registered Midwives to join our midwifery teams.🏖️ Scarborough Hospital🌳 CommunityFull-time and part-time hours are considered. More details at https://ow.ly/WcuT50STJT0hashtag#NHSJobs hashtag#NHSCareers hashtag#Midwife\n      \n    \n  \n          \n          …more",
      "trust": "York and Scarborough Teaching Hospital NHS Foundation Trust"
    },
    "object2": {
      "url": "https://www.linkedin.com/company/northern-lincolnshire-and-goole-nhs-foundation-trust/",
      "post": "The Podiatry service strives to provide a high standard of evidenced based podiatric care within a variety of settings including GP surgeries, community clinics and hospital based multidisciplinary diabetes centres.This is an excellent opportunity to join an enthusiastic and friendly team; supported in regular clinical supervision, mentorship and development opportunities.Where the successful applicant does not meet all essential criteria this post may be offered as a band 5-6 developmental opportunity, working towards set objectives in order to progress from Band 5 to Band 6. For more information and to apply: https://lnkd.in/dWF-ba8A\n      \n    \n  \n          \n          …more",
      "trust": "Northern Lincolnshire and Goole NHS Foundation Trust"
    }
  },
  "method": "POST",
  "headers": {
    "host": "cloud.activepieces.com",
    "accept": "*/*",
    "cf-ray": "8b082070a9eab393-MAN",
    "origin": "null",
    "cdn-loop": "cloudflare",
    "priority": "u=1, i",
    "x-real-ip": "172.70.58.46",
    "cf-visitor": "{\"scheme\":\"https\"}",
    "connection": "Upgrade",
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
    "cf-ipcountry": "GB",
    "content-type": "application/json",
    "content-length": "1459",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "cross-site",
    "accept-encoding": "gzip, br",
    "accept-language": "en-GB,en;q=0.9",
    "x-forwarded-for": "172.70.58.46",
    "cf-connecting-ip": "51.191.67.53",
    "x-forwarded-host": "cloud.activepieces.com",
    "x-forwarded-port": "443",
    "x-forwarded-proto": "https",
    "x-forwarded-server": "357498a82a7a"
  },
  "queryParams": {}
}

Hello @LloydBH ,

Based on this payload example, do you have an example of an array of results? I’m trying to reproduce the issue.

So I want to send each object in an email as per the following;

<h1>TRUST</h1>
<p><a href="URL" target="_blank">URL</a></p>
<span>POST</span>

So the above payload would result in

<h1>York and Scarborough Teaching Hospital NHS Foundation Trust</h1>
<p><a href="https://www.linkedin.com/company/york-and-scarborough-teaching-hospitals-nhs-foundation-trust/" target="_blank">https://www.linkedin.com/company/york-and-scarborough-teaching-hospitals-nhs-foundation-trust/</a></p>
<span>Midwifery on the North Yorkshire coast!Come and join our friendly team on the coast! We are looking for Band 6 NMC Registered Midwives to join our midwifery teams.🏖️ Scarborough Hospital🌳 CommunityFull-time and part-time hours are considered. More details at https://ow.ly/WcuT50STJT0hashtag#NHSJobs hashtag#NHSCareers hashtag#Midwife\n      \n    \n  \n          \n          …more"</span>
<h1>Northern Lincolnshire and Goole NHS Foundation Trust</h1>
<p><a href="https://www.linkedin.com/company/northern-lincolnshire-and-goole-nhs-foundation-trust/" target="_blank">https://www.linkedin.com/company/northern-lincolnshire-and-goole-nhs-foundation-trust/</a></p>
<span>The Podiatry service strives to provide a high standard of evidenced based podiatric care within a variety of settings including GP surgeries, community clinics and hospital based multidisciplinary diabetes centres.This is an excellent opportunity to join an enthusiastic and friendly team; supported in regular clinical supervision, mentorship and development opportunities.Where the successful applicant does not meet all essential criteria this post may be offered as a band 5-6 developmental opportunity, working towards set objectives in order to progress from Band 5 to Band 6. For more information and to apply: https://lnkd.in/dWF-ba8A\n      \n    \n  \n          \n          …more</span>

being sent to the Send Email piece in the body input on the piece. Hopefully that is clearer. Thank you for your help.

@LloydBH ,

Based on your sample input, the body contains objects of objects rather than an array of objects. This might be causing issues with the loop, as it requires an array. Please revalidate the webhook output; it should look something like the following

"body": [
    {
      "url": "https://www.linkedin.com/company/york-and-scarborough-teaching-hospitals-nhs-foundation-trust/",
      "post": "Midwifery on the North Yorkshire coast!Come and join our friendly team on the coast! We are looking for Band 6 NMC Registered Midwives to join our midwifery teams.🏖️ Scarborough Hospital🌳 CommunityFull-time and part-time hours are considered. More details at https://ow.ly/WcuT50STJT0hashtag#NHSJobs hashtag#NHSCareers hashtag#Midwife\n      \n    \n  \n          \n          …more",
      "trust": "York and Scarborough Teaching Hospital NHS Foundation Trust"
    },
    {
      "url": "https://www.linkedin.com/company/northern-lincolnshire-and-goole-nhs-foundation-trust/",
      "post": "The Podiatry service strives to provide a high standard of evidenced based podiatric care within a variety of settings including GP surgeries, community clinics and hospital based multidisciplinary diabetes centres.This is an excellent opportunity to join an enthusiastic and friendly team; supported in regular clinical supervision, mentorship and development opportunities.Where the successful applicant does not meet all essential criteria this post may be offered as a band 5-6 developmental opportunity, working towards set objectives in order to progress from Band 5 to Band 6. For more information and to apply: https://lnkd.in/dWF-ba8A\n      \n    \n  \n          \n          …more",
      "trust": "Northern Lincolnshire and Goole NHS Foundation Trust"
    }
  ],

If the format is not an array or list, you can add code step after the webhook step to convert it into an array of objects, as shown below.