Forum Discussion
Hi @aditya.gupta41,
Yes you can absolutely create as many tables as you want. Let me give you an example.
Let’s say this is our dataset:
[
{
"people": [
{
"name": "John",
"age": 30,
"car": null
},
{
"name": "Robert",
"age": 25,
"car": "Ford Mustang"
},
{
"name": "Leon",
"age": 38,
"car": "Jeep"
},
{
"name": "Elizabeth",
"age": 21,
"car": null
}
],
"items": [
{
"item": "Sunglasses",
"price": "$5.00"
},
{
"item": "Smartwatch",
"price": "$22.00"
},
{
"item": "Wireless Headphones",
"price": "$18.00"
}
]
}
]
Now, if we want to create two tables, I suggest you to use the XML Generator snap together with Apache Velocity.
From this dataset we can easily create two tables and even style them with the XML generator snap.
The following code goes into the XML generator snap.
<html>
<head>
<style>
table {
width: 100%;
}
thead th {
background: black;
color: white;
}
tbody tr:nth-child(even) {
background: #D9D9D9;
}
td {
padding: 5px;
}
</style>
</head>
<body>
<h1>This is the 'people' table</h1>
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
<th>car</th>
</tr>
</thead>
<tbody>
#foreach ( $person in $people )
<tr>
<td>$person.name</td>
<td>$person.age</td>
<td>$person.car</td>
</tr>
#end
</tbody>
</table>
<h1>This is the 'items' table</h1>
<table>
<thead>
<tr>
<th>item</th>
<th>price</th>
</tr>
</thead>
<tbody>
#foreach ( $item in $items )
<tr>
<td>$item.item</td>
<td>$item.price</td>
</tr>
#end
</tbody>
</table>
</body>
</html>
Next, just place an Email Sender snap, add your account settings and in the property “Email type” select “HTML text”. Once you set this, just enable the expression for the “Template body” property and use the following expression to remove the “\n” characters.
$xml.replaceAll("\n", "")
And this is the preview of the two tables created with the sample dataset.
- SpiroTaleski2 years agoValued Contributor
jfpelletier If you execute the pipeline(not validate), do you getting the same error from the HTTP Client Snap?
- jfpelletier2 years agoContributor
Hello SpiroTaleski,
Not sure if it's related, but I managed to solve the issue last night with the help of a support representative helping me with a very similar issue.
I had quite a lot of opened snaps in the Designer (left-overs from previous attempts...), and at least one of them seem to have interfered somehow because when we disabled all the open snaps that were doing nothing, the issue disappeared...
We were not able to pin-point the exact snap that was apparently causing the issue, anyway it's resolved and working today... 🙂
Thanks a lot for taking the time to look into this issue and suggesting solutions! 🙂
Kind regards,
JF
Hi jfpelletier ,
I don't know if this applies to the issue that you are having where there's no valid key name to the form where you are setting the name value
EmEm
- SpiroTaleski2 years agoValued Contributor
Why you didn't use the Mapper snap for building the JSON?
- jfpelletier2 years agoContributor
Hello SpiroTaleski,
Thanks for your comment. Actually, I already tried using a mapper right after the JSON generator, and the mapper has no issue seeing the values and doing the mapping:
Still, the following HTTP Client snap says that the values are null...
Could this be related to what alchemiz reported last Saturday?
Thanks!
JF
- SpiroTaleski2 years agoValued Contributor
Are you trying to send above fields in the body of the API request?
Can you please share the HTTP Client Snap configuration?
- jfpelletier2 years agoContributor
Hello SpiroTaleski,
I'm trying to send the fields as multipart payload. Please see screenshot from the HTTP Client configuration:
And this is what it looks like in the Expression Builder:
Thanks!
JF