Add Attachments to Clickup

As you may know, clickup is a highly flexible and powerful project management tool. Attachments are really important on any project. Would be good to have the add attachments operation to a clickup node.

@RicardoE105 pointed a super relevant note about this workflow, and the thing is that the ClickUp API allows you to upload just one file at a time, so you need to split the binary data into multiple records to do the POST.

Also, i’m unsure if its a bug or my setup, but when I hardcode the task URL where I want to attach the files it works, but not if I set the URL through an expression.

    {
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "list",
        "application": "appXK4YYl2hKGCNCJ",
        "table": "T1",
        "downloadAttachments": true,
        "downloadFieldNames": "Attachment",
        "additionalOptions": {}
      },
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        520,
        300
      ],
      "credentials": {
        "airtableApi": "asasasa"
      }
    },
    {
      "parameters": {
        "functionCode": "const results = [];\n\nfor (const item of items) {\n  for (const key of Object.keys(item.binary)) {\n      results.push({ \n      json: { \n        binaryProperty: key,\n        fileName: item.binary[key].fileName\n      },\n      binary: { \n        [key]: \n        item.binary[key]\n      }\n    })\n  }\n}\n\nreturn results;"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        740,
        300
      ]
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "requestMethod": "POST",
        "url": "https://api.clickup.com/api/v2/task/429rc2/attachment",
        "jsonParameters": true,
        "options": {
          "bodyContentType": "multipart-form-data"
        },
        "sendBinaryData": true,
        "binaryPropertyName": "=attachment:{{$node[\"Function\"].json[\"binaryProperty\"]}}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1020,
        300
      ],
      "credentials": {
        "httpHeaderAuth": "Clickup"
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@infinitegroup hi, how can i make your code work on node js? i am trying to split streams but click up gives me 400 error, my files or csv and image, thanks