Can't pass an item field to url in a request node

Hi i am automatin a website scrapper:
1st) set an item with an url - I need this step to update the data for the previous day
https://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-referenciais-bmf-ptBR.asp?data1=20220308&slcTaxa=DIC

2nd) I pass this item to a request node using this expression {{$json[“url”]}}
the result seems right: https://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-referenciais-bmf-ptBR.asp?data1=20220308&slcTaxa=DIC
But I got this error:
ERROR: UNKNOWN ERROR - check the detailed error for more information
The “url” argument must be of type string. Received undefined

I also tried to pass just the base url and the parameter data, but it didn’t work as well, it seems it is passing an empty string when running although the result feedback seems alright.

1 Like

{
“name”: “taxa-b3-scrap”,
“nodes”: [
{
“parameters”: {},
“name”: “Start”,
“type”: “n8n-nodes-base.start”,
“typeVersion”: 1,
“position”: [
360,
420
]
},
{
“parameters”: {
“url”: “=https://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-referenciais-bmf-ptBR.asp?data1=20220308&slcTaxa=DIC”,
“responseFormat”: “string”,
“options”: {},
“queryParametersUi”: {
“parameter”: [
{
“name”: “data1”,
“value”: “={{$json[“data1”]}}”
},
{
“name”: “slcTaxa”,
“value”: “={{$json[“slcTaxa”]}}”
}
]
}
},
“name”: “HTTP Request”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 1,
“position”: [
760,
280
],
“executeOnce”: false,
“retryOnFail”: false
},
{
“parameters”: {
“extractionValues”: {
“values”: [
{
“key”: “taxa”,
“cssSelector”: "table "
}
]
},
“options”: {
“trimValues”: “=”
}
},
“name”: “HTML Extract”,
“type”: “n8n-nodes-base.htmlExtract”,
“typeVersion”: 1,
“position”: [
960,
280
]
},
{
“parameters”: {
“functionCode”: “var new_items = []\nres = items[0].json.taxa.split(/\n/)\nres = res.filter(i => i)\nres = res.slice(3,)\nfor (let i = 0; i < res.length; i=i+2) {\n new_items.push({json: {‘days’: res[i], ‘taxa’: res[i+1]}})\n}\n\nreturn new_items”
},
“name”: “Function1”,
“type”: “n8n-nodes-base.function”,
“typeVersion”: 1,
“position”: [
1160,
280
]
},
{
“parameters”: {
“triggerTimes”: {
“item”: [
{
“hour”: 23
}
]
}
},
“name”: “Cron”,
“type”: “n8n-nodes-base.cron”,
“typeVersion”: 1,
“position”: [
360,
280
]
},
{
“parameters”: {
“functionCode”: “const moment = require(‘moment’)\nconst data1 = moment().subtract(1, ‘days’).format(‘YYYYMMDD’)\nconst slcTaxa = ‘DIC’\nconst url = String(https://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-referenciais-bmf-ptBR.asp?data1=${data1}&slcTaxa=${slcTaxa})\nconst item = {}\nitem.json = {data1: data1, slcTaxa: slcTaxa, url: url}\nreturn [item]”
},
“name”: “Function”,
“type”: “n8n-nodes-base.function”,
“typeVersion”: 1,
“position”: [
560,
280
]
}
],
“connections”: {
“HTTP Request”: {
“main”: [
[
{
“node”: “HTML Extract”,
“type”: “main”,
“index”: 0
}
]
]
},
“HTML Extract”: {
“main”: [
[
{
“node”: “Function1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Start”: {
“main”: [
[
{
“node”: “Function”,
“type”: “main”,
“index”: 0
}
]
]
},
“Cron”: {
“main”: [
[
{
“node”: “Function”,
“type”: “main”,
“index”: 0
}
]
]
},
“Function”: {
“main”: [
[
{
“node”: “HTTP Request”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“active”: false,
“settings”: {},
“id”: 1003
}

Hi I just found the solution. {{$json[“url”].toString()}}

Just converting to string fixed the problem in both methods passing the entire url or adding the query parameters.

3 Likes