Invalid URI

I’m getting an invalid uri error when using the http node. I’m populating the URL like this:

{{$node["config"].json["api"]}}/api/v2/surveys-media/{{$json["encoded"]}}

The “encoded” uri is coming from a function node where I encodeURIComponent like this:

const att = $node.Webhook.json.body._attachments;

return att.map(att => ({
  json: {
    filename: att.filename,
    encoded: encodeURIComponent(att.filename),
  } 
}));

And I am using auth - with a jwt header Authorization.

The error I’m getting is:

Error: RequestError: Error: Invalid URI "/api/v2/surveys-media/forms%2Fattachments%2Fd1d3db045a5042aeaa43dfc96ca2213f%2F8e628ad5-0d1e-423f-99e5-9f0e42fde003%2Fmaxresdefault-13_29_24.jpg"
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest.node.js:762:27)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:369:47

Has anyone run into this before?

Looks for me like the first part {{$node["config"].json["api"]}} does not resolve to anything and so it the URL invalid as the whole http://???? domain part is missing.

You know - you’re absolutely right. After I hard coded the url (changed the template to the literal https://… text and replacing the templated variable it worked.

It does show as resolving (see below):

Edit:

I realized what it was. the Config item is a function that only returns one item in the array. This particular node executes on each item so it was looking for config[0], config[1], etc. I needed to reference config[0] in each iteration.

Great to hear that you found the problem!

Have fun!

1 Like