Hi, I’m using Postmark as my transactional email provider and I’d like to send a custom email to my customers using a template that I have created.
One of the variables is called “issues” which expects an array of objects like this:
"issues": [
{
"title": "issue"
},
{
"title": "issue 2"
}
]
I used a function node to create an array of objects that appears to be in the same format, but when I run the http request node, I get an error regarding the issues variable.
Feels like I’m really close, but not sure how to adjust the format of my issues array to be accepted by Postmark.
Here’s a video - Loom | Free Screen & Video Recording Software
Hey @richardjlo , thanks for providing the context of your usecase. typically the JSON parameter needs to be a string to get successfully parsed before being sent to an API endpoint, thus stringifying the “issues” parameter should solve the problem.
Here is a workflow where I used the same data (you can use https://webhook.site to receive the HTTP requests)
{
"nodes": [
{
"parameters": {
"requestMethod": "POST",
"url": "WEB HOOK site",
"jsonParameters": true,
"options": {
"bodyContentType": "json"
},
"bodyParametersJson": "={\n\"issue\":{{JSON.stringify($node[\"Function\"].json[\"issues\"])}}\n}"
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
750,
280
]
},
{
"parameters": {
"functionCode": "\nitems = [\n {\n json:{\n \"issues\": [\n\t {\n\t\t \"title\": \"issue\"\n\t },\n\t {\n\t\t \"title\": \"issue 2\"\n\t }\n ] \n }\n }\n]\n\nreturn items;"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
560,
280
]
}
],
"connections": {
"Function": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}```
Let me know if that helps!
Thanks so much! Yes, that’s totally the issue. I ended up creating the body in a Set node based on @RicardoE105’s advice and that worked out for me.