Question about custom node routing

Hey everyone

I am trying to switch from programatic to declarative node building style and am trying to keep everything as modular as possible

Quick question for those with more experienced than me

Can you stack url paths? Meaning can you set url: '/projects' in a project resource field then add, for example, a url: '=/{{$parameter.projectId}}/invitations' under the an operation to make the path: https://baseurl/projects/projectid/invitations?

I assumed this was possible so I just want to check to make sure i’m not missing something.

I tried it here like this in resource

resources = [
...
 {
    name: 'Project Collaborator',
    value: 'projectCollaborator',
    routing: {
      request: {
      url: '/projects/'
      }
    }
 },
...
]

Then in operation like this

fields = [
  {
    displayName: 'Project ID',
    name: 'projectId',
    type: 'string',
    required: true,
    default: '',
    routing: {
      request: {
        url: '=/{{$parameter.projectId}}/invitations'
      },
    },
    ...
  },
]

As shown I get a 404 error.

If i remove the url from the resource and add the full path in the operation it works.

Is this the intended way or am i doing something wrong?

Also, is there an easy way to debug (see) your request? I can’t figure out how to actually see it so I’m just relying on response codes

Thanks in advance :grin:



n8n version: 1.27.2

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I’m not an expert in custom nodes, but are you sure you have to use the n8n syntax here and not the regular js? Like

url: `=/${$parameter.projectId}/invitations`

@barn4k I don’t think that works because with their declarative nodes they are trying to keep you from using JS and to just create the API routing with their declarative syntax.

They show it like that in their declarative nodes docs.

Either way, that part works. When I put the full url path in just one field it successfully passes the project ID and called the API successfully.

I want to know if I can add the URL path in two (or more) parts instead of at the field level

1 Like