Custom node issue

Describe the problem/error/question

When coding a custom declarative-style (!) node, I came across an issue (which may or may not be an actual issue). In Operation’s request object I wanted to access the parameters from credentials file. Say I have an alternative base url set or just any value set in credentials.

For instance, in credentials, I would have a parameter set like so:

{
	displayName: 'Custom Header',
	name: 'customHeader',
	type: 'string',
	placeholder: 'n8n rules',
	default: '',
}

In credentials file itself I can reference this parameter value (in authenticate for instance) with:

authenticate: IAuthenticateGeneric = {
	type: 'generic',
	properties: {
		headers: {
			'Custom-Header': '={{ $credentials.customHeader }}',
		},
	},
};

but in the node’s code this type of templating doesn’t work. I can easily get the value in execute by pulling the credentials, but I wish to keep the node declarative.

The templating itself does work, because it works for parameters like ={{ $parameter.pName }} in the node’s code. Not sure if using credentials parameters is meant to work or not, but I never made it work.

While checking with echo servers. I see that the value is always empty for credential parameters pulled into the node’s code with templating. My question for the community: is it supposed to work, or credential parameters don’t work through templating in the node’s code?

UPD1:
here you can see an example code for this and try it in action (will obviously need to deploy):

UPD2:
interesting observation, in the requestDefault portion of the Node’s code the '={$credentials.customHeader}' does work, it is only in the Operation’s options routing where it’s not working.

UPD3:
updating to the latest 1.97.1 didn’t help (I didn’t think it would, I am just desperate).

Finally (not that it matters, but):
Docker
Postgres
1.95.3

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