How to Build Array

Mautic has recently released it’s new Custom Objects Plugin (which is super powerful to those that use Mautic.)

I am trying to test the API, however due to my limited knowledge I need help building the correct http request (node).

This is the example of the post I need to build (Reference here)

{
    "email": "[email protected]",
    "firstname": "John",
    "customObjects": {
        "data": [
            {
                "id": 1,
                "alias": "products",
                "data": [
                    {
                        "id": 23,
                        "name": "Hello From API2",
                        "attributes": {
                            "website": "https://mautic.org",
                            "in-stock": 45,
                            "multi": ["yellow", "blue"],
                            "sku": "2348720",
                            "color": "brown"
                        }
                    }
                ]
            }
        ]
    }
}

Hey @Surge.Media,

Depending on what you want to do there are a few options, The quickest is to just take what you have and use the Raw parameters option and paste it in and use expressions for the bits you want to dynamically want to change.

Another option would be to use a function node to build out the data to post .

Hey @Jon thanks for your quick response - unfortunately I did not understand anything :man_shrugging:

I have tried just copying this and pasting it into the canvas - but this is obviously not the way to do it…

Hey @Surge.Media,

Try starting with this…

Thanks @Jon

When i am copying the “this workflow’s code” into my n8, i am getting:
“The node is not valid as its type (n8n-nodes-base.httpRequest) is unknown”

Hey @Surge.Media,

What version of n8n are you running?

If you double click the HTTP Request node in the post you should be able to see what I have done.

1 Like

@Jon thanks for your patience. It was an old version of n8n. I can now see what you have done!
Appreciate the help so far.
I am going to try and tweak it to suit my needs

1 Like