HTTP Request - The "url" argument must be of type string

Describe the issue/error/question

I have created a flow in N8N that takes a CSV file, converts it to a spreadsheet, downloads photos and videos, and saves it to Google Drive. However, I am having trouble making the request for the file.

When I run this flow, I get this error on the HTTP Request node:

“The “url” argument must be of type string.”

I have tried converting it to a string using the expression below but got the same response.

{{$node[“IF3”].json[“videoUrl”].toString()}}

What is the error message (if any)?

The “url” argument must be of type string. Received undefined

{"status":"rejected","reason":{"code":"ERR_INVALID_ARG_TYPE","cause":{"code":"ERR_INVALID_ARG_TYPE"},"error":{"code":"ERR_INVALID_ARG_TYPE"},"options":{}}}

Please share the workflow

Share the output returned by the last node

[
{
"postUrl":
"https://www.instagram.com/p/CqJyGJzr1uI/",
"description":
"1 ou 2? Comenta o seu favorito!😍 • • • • #maquiagemlovers #makeup #makeuptutorial #maquiagemperfeita #maquiagemprofissional #maquiagempararevenda #make #maquiagem #maquiagemtutorial #explorar",
"commentCount":
0,
"likeCount":
323,
"pubDate":
45009.052037037036,
"likedByViewer":
"false",
"isSidecar":
"true",
"type":
"Video",
"profileUrl":
"https://www.instagram.com/maquiagens.decorada",
"username":
"maquiagens.decorada",
"imgUrl":
"https://scontent-yyz1-1.cdninstagram.com/v/t51.2885-15/337547302_867604434333244_7791282847450897423_n.jpg?stp=dst-jpg_e15&_nc_ht=scontent-yyz1-1.cdninstagram.com&_nc_cat=104&_nc_ohc=NQegB2_UgpIAX_W1CDP&edm=AOQ1c0wBAAAA&ccb=7-5&oh=00_AfCc4f_MvV0fN6c2AYLMy6wsQPbAJ5dCC2aIrVb14LMXeQ&oe=641F2C52&_nc_sid=8fd12b",
"videoUrl":
"https://scontent-yyz1-1.cdninstagram.com/v/t50.2886-16/337228048_438296888493951_2576282168697214685_n.mp4?_nc_ht=scontent-yyz1-1.cdninstagram.com&_nc_cat=103&_nc_ohc=eF6VTFX7g7AAX_HieZN&edm=AOQ1c0wBAAAA&ccb=7-5&oh=00_AfBoVj4DET4WSi5VaPkx5CXLfspVRRk4iAigjdcLvYhCIw&oe=641F2331&_nc_sid=8fd12b",
"viewCount":
2715,
"postId":
3065200780244887000,
"timestamp":
45009.54826427083,
"query":
"https://www.instagram.com/maquiagens.decorada/"
},
{
"postUrl":
"https://www.instagram.com/p/CqJx6hnrpeP/",
"description":
"Gostou? Comenta aqui!😍 • • • • #maquiagemlovers #makeup #makeuptutorial #maquiagemperfeita #maquiagemprofissional #maquiagempararevenda #make #maquiagem #maquiagemtutorial #explorar",
"commentCount":
2,
"likeCount":
255,
"pubDate":
45009.0509375,
"likedByViewer":
"false",
"isSidecar":
"true",
"type":
"Video",
"profileUrl":
"https://www.instagram.com/maquiagens.decorada",
"username":
"maquiagens.decorada",
"imgUrl":
"https://scontent-yyz1-1.cdninstagram.com/v/t51.2885-15/337310073_192703846833614_5736235136464639403_n.jpg?stp=dst-jpg_e15&_nc_ht=scontent-yyz1-1.cdninstagram.com&_nc_cat=102&_nc_ohc=Ab7Yap4mRawAX-QqwpD&edm=AOQ1c0wBAAAA&ccb=7-5&oh=00_AfBbIpX1_fdxR1AtRopS_pZxfc_C5RDNRQAaKhARZKUj9Q&oe=641F4F4D&_nc_sid=8fd12b",
"videoUrl":
"https://scontent-yyz1-1.cdninstagram.com/v/t50.2886-16/329781666_1653661168387875_944566412754934320_n.mp4?_nc_ht=scontent-yyz1-1.cdninstagram.com&_nc_cat=103&_nc_ohc=_pQawp06yAUAX_0MXkH&edm=AOQ1c0wBAAAA&ccb=7-5&oh=00_AfC1p4CfSZNX7GvFH5XPl5fcCfYip8bbd_T7Wyw219vjWg&oe=641F2AEE&_nc_sid=8fd12b",
"viewCount":
2037,
"postId":
3065200236299157500,
"timestamp":
45009.54826427083,
"query":
"https://www.instagram.com/maquiagens.decorada/"
},

Information on your n8n setup

  • n8n version: 0.221.2

  • Database you’re using (default: SQLite):

  • Running n8n with the execution process [own(default), main]:

  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hi @Lellis,

The problem is that for some entries of “Spreadsheet” table, videoUrl is not set.
It works fine, if you add one more IF.
Check out this updated workflow:

{
  "name": "workflow-24485",
  "nodes": [
    {
      "parameters": {},
      "id": "c3b913f5-f8fa-4d44-9224-92c4fab7d29d",
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        1780,
        920
      ]
    },
    {
      "parameters": {
        "options": {
          "rawData": false,
          "readAsString": true
        }
      },
      "name": "Spreadsheet File",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 1,
      "position": [
        2240,
        920
      ],
      "id": "ea48f474-3b2d-4aec-8c4b-e42436a4175e"
    },
    {
      "parameters": {
        "url": "https://cache1.phantombooster.com/OVzuvLDZhiw/H4ohphB0Ukk5YXDAyZWaew/maquiagens.decorada.csv",
        "responseFormat": "file",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        2000,
        920
      ],
      "id": "fb0c3005-f8ea-47b4-b3b9-98d6394f4b55"
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$node[\"IF-CSV\"].json[\"likeCount\"]}}",
              "operation": "largerEqual",
              "value2": 5000
            },
            {
              "value1": "={{$node[\"IF-CSV\"].json[\"commentCount\"]}}",
              "operation": "largerEqual",
              "value2": 10
            }
          ]
        },
        "combineOperation": "any"
      },
      "id": "46da873d-8c08-4cfe-a72c-39094ac29526",
      "name": "IF1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        2740,
        1020
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"IF-CSV\"].json[\"type\"]}}",
              "value2": "Video"
            }
          ]
        }
      },
      "id": "15474215-41fc-4475-858c-bd353c15743b",
      "name": "IF2",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        2760,
        1200
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$node[\"IF2\"].json[\"likeCount\"]}}",
              "operation": "largerEqual",
              "value2": 10000
            },
            {
              "value1": "={{$node[\"IF2\"].json[\"viewCount\"]}}",
              "operation": "largerEqual",
              "value2": 10000
            }
          ]
        },
        "combineOperation": "any"
      },
      "id": "f1d474eb-896b-474d-93b4-23ab76109e06",
      "name": "IF3",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        3140,
        1420
      ],
      "executeOnce": false
    },
    {
      "parameters": {
        "url": "={{ $json[\"videoUrl\"] }}",
        "responseFormat": "file",
        "options": {}
      },
      "name": "HTTP Request3",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        4000,
        1440
      ],
      "id": "46cbb98c-5608-4edf-ad8b-a610ee06af02",
      "executeOnce": false
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "binaryData": true,
        "name": "={{$binary.data.fileName}}",
        "resolveData": true,
        "parents": [
          "1lx_uQZ8Qe09qxuLsja_XaD5QTGbsTakg"
        ],
        "options": {}
      },
      "id": "0a22202c-3cb6-4779-9625-4fbcc7517684",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 2,
      "position": [
        4200,
        1440
      ],
      "credentials": {
        "googleApi": {
          "id": "6",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Spreadsheet File\"].json[\"type\"]}}",
              "value2": "Photo"
            }
          ]
        }
      },
      "id": "024a0203-2683-49cc-9084-711214c25505",
      "name": "IF-CSV",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        2520,
        1120
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ typeof $json.videoUrl }}",
              "value2": "string"
            }
          ]
        }
      },
      "id": "8bf82579-4abe-4245-aa11-e149fe894ef6",
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        3580,
        1440
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet File": {
      "main": [
        [
          {
            "node": "IF-CSV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Spreadsheet File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF2": {
      "main": [
        [
          {
            "node": "IF3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF3": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request3": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF-CSV": {
      "main": [
        [
          {
            "node": "IF1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        []
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "HTTP Request3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "versionId": "5f185f86-b109-44b8-8248-db86425baa9e",
  "id": "4",
  "meta": {
    "instanceId": "e6067b9d12713f2c8e2e9139e3b4f8b2eafdd93836eb40bcabdcd7a53fdc5584"
  },
  "tags": []
}```

Cheers
1 Like

I just realized that some fields were empty! That’s why it worked the first time I ran it and not the second time!

Thanks a lot for the help!

One last thing, if possible. I wanted to add a node to this workflow that creates a folder in Drive with the “username” that is in the spreadsheet so that I can save the files there. However, when I insert it into the workflow, it creates more than one folder. And when I enable it to execute only once, it doesn’t send the data from the spreadsheet forward. Do you have any ideas on how I can solve this?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.