Sync two different softwares

Hello everyone. I’m completely new to n8n. I installed it on our server trying to sync two softwares that we use in our company.

As someone may know in Italy we are obliged to use e-invoices. For this kind of action we use fatture in Cloud which is accessible through API.

https://api.fattureincloud.it/v1/documentation/dist/?version=000906

I would like to start by syncing the clients and suppliers list, ie “anagrafiche”.

Let’s get the list of the clients. From what I understand I should use an http call and authenticate to the server with an API key and a password. Can someone help me with the first node?

Welcome to the community @devishian

The example below should do it. Just add your api_key and api_uid. For the record. I just followed the docs, did not test it cuz I do not have an account.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://api.fattureincloud.it/v1/clienti/lista",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "api_uid",
              "value": "your uuid"
            },
            {
              "name": "api_key",
              "value": "your api key"
            }
          ]
        },
        "queryParametersUi": {
          "parameter": [
            {}
          ]
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        550,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Thanks. I was able to access to both of the lists. Next step and some other issues.

This is the first list that I get from one software. I am not able to transform it in a table, maybe since it is grouped under “lista clienti”

[
{
"lista_clienti": [
{
"id": "40698061",
"nome": "xxxx",
"referente": "",
"indirizzo_via": "Via xxx",
"indirizzo_cap": "86100",
"indirizzo_citta": "CAMPOBASSO",
"indirizzo_provincia": "CB",
"indirizzo_extra": "",
"paese": "Italia",
"mail": "",
"pec": "[email protected]",
"tel": "",
"fax": "",
"piva": "0163833150704",
"cf": "GBRGFR75H11Z112F",
"termini_pagamento": "0",
"pagamento_fine_mese": false,
"val_iva_default": "",
"desc_iva_default": "",
"extra": "",
"PA": false,
"PA_codice": "M5UXCR1"
},
{
"id": "40698109",
"nome": "A.M. xxxxx.",
"referente": "",
"indirizzo_via": "Via xxx",
"indirizzo_cap": "21012",
"indirizzo_citta": "CASSANO MAGNAGO",
"indirizzo_provincia": "VA",
"indirizzo_extra": "",
"paese": "Italia",
"mail": "",
"pec": "",
"tel": "",
"fax": "",
"piva": "035653550122",
"cf": "0356535550122",
"termini_pagamento": "0",
"pagamento_fine_mese": false,
"val_iva_default": "",
"desc_iva_default": "",
"extra": "",
"PA": false,
"PA_codice": "USAL8PV"
}
]
}
]

On the other side (the other software) I was able with basic auth to access to a json table but it is only an index. By accessing to this url I have a list of customers:

https://myurl/api/QU0gU3ZpbHVwcGkgSW1tb2JpbGlhcmk/ec37c11e-2b67-49c6-8a58-6eccb7dd75ee/index.json

and I get this list

image

which is basically a list of links to the single JSON of each client. For example the first one is accessible through https://myurl/api/QU0gU3ZpbHVwcGkgSW1tb2JpbGlhcmk/00448c03-eefd-435b-8078-edc442bad296.json

So I think that I have to create something “recursive”.

Thanks for your help and for the great software

This is the first list that I get from one software. I am not able to transform it in a table, maybe since it is grouped under “lista clienti”

Yes, you need to use a function node to map the data to something n8n “understands”. Check the example below.

Example
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://another-example-y4awmm2s64y5.runkit.sh/",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        510,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return items[0].json.lista_clienti.map((client => ({ json: client })))"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        740,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

On the other side (the other software) I was able with basic auth to access to a json table but it is only an index. By accessing to this url I have a list of customers:

That is not a problem, just map that array to an array of items (similarly to what I did in the example above) and then use expressions to reference the id in the HTTP node.