Objects and Arrays with Sendgrid

Options
Hi all,

I'm trying to implement the Sendgrid API, but am currently stuck with some customisations.
[image.png]In Xano, I have "personalizations" for my Sendgrid function set to intake the following data:

"personalizations": [
{
"to": Array of objects with  "name" and "email",
dynamic_template_data": Object of key/value pairs
]

However, when I try to pass data to this function stack, I can't seem to get the data types formatted correctly. The following data is being passed instead:
"personalizations": [
{
"to": [[]],
"dynamic_template_data": []
}
]

I have my API call configured as such:
"to":[image.png]"dynamic_template_data": [image.png]Could someone point out what I'm doing wrong here?

The portion of Sendgrid's documentation which I'm referring to can be found here: [image.png]

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Sengrid says "personalizations can be thought of as an envelope - it defines who should receive an individual message and how the message should be handled"

    I might suggest constructing this in a variable first in the function stack. This will give you much more flexibility in formatting it and access to any functions like loops or array functions you might need, then you can add the entire thing to the params section where appropriate of the external API call. 

    It may also be helpful if they have an example body in the documentation. You could use the import JSON action to help construct it