Write JSON File to external ftp server

Hello folks

is it possible go write a JSON File to an external Webserver via FTP?

Hey @jtiebel,

That shouldn’t be a problem once you get your file you can drop in the ftp node add your ftp credentials for the server and upload the data.

Maybe its possible to get an example form you?

I have not a file directly. I get json data from an api via http request and want so save this data in a .json file on my web server that I can access it and work with the data in a later stage. Maybe there is a better way to achieve this?! But writing a file I thought is pragmatic…

Hey @jtiebel,

An example is no problem, I set a reminder to pop one together this morning for you. Just wanted to get a quick reply to you last night so you could have a look.

Give me a couple of hours to have some coffee and get to my computer and I will sort something out.

easy man, no stress. thanks much for your help!

Hey @jtiebel,

I was just having a chat with @harshil1712 on Discord during the Certification Course voice chat and he mentioned there is already an example on the workflows site. Took a quick look and found this which should do what you are after.

1 Like

its not working. execution is successful but file is empty… could you be so kind and advise?

{
  "nodes": [
    {
      "parameters": {
        "url": "https://diga-api.bfarm.de/thcvz/apps",
        "options": {}
      },
      "name": "request_apps",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        -290,
        550
      ]
    },
    {
      "parameters": {
        "operation": "upload",
        "path": "test.json",
        "binaryData": false,
        "fileContent": "={{$node[\"request_apps\"].json[\"data\"]}}"
      },
      "name": "FTP",
      "type": "n8n-nodes-base.ftp",
      "position": [
        860,
        330
      ],
      "typeVersion": 1,
      "credentials": {
        "ftp": "h44633_diga"
      }
    }
  ],
  "connections": {
    "request_apps": {
      "main": [
        [
          {
            "node": "FTP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Try this…

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://diga-api.bfarm.de/thcvz/apps",
        "responseFormat": "file",
        "options": {}
      },
      "name": "request_apps",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "operation": "upload",
        "path": "/home/user/test.json"
      },
      "name": "FTP",
      "type": "n8n-nodes-base.ftp",
      "position": [
        720,
        300
      ],
      "typeVersion": 1,
      "credentials": {
        "ftp": {
          "id": null,
          "name": "h44633_diga"
        }
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "request_apps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "request_apps": {
      "main": [
        [
          {
            "node": "FTP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

I have changed the HTTP request to return a file then set the FTP node to use the data object instead. Not sure why the file content option isn’t working but this approach does what you need.

This is working great, thanks much for your support!

1 Like