Node with multiple credentials : "Create new Credential" user action always use first credential type

Describe the problem/error/question

I defined a node using multiple credentials like this :

credentials: [
	{
		name: 'geoptisSolutionApi',
		required: true,
	},
	{
		name: 'hubspotAppToken',
		required: true,
	},
],

It works well using this node, user can choose existing credentials in the list, but if he try to add a new credential on the second credential type


the displayed form use the first credential type, so he cannot add a new credential for the second credential type

Information on your n8n setup

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

Hey @guillaume.voyau,

Welcome to the community :raised_hands:

Typically the nodes don’t use 2 credentials so there could be something there but are you able to share the full code for your node so we can take a look?

Hey @Jon, thank’s for your answer.

This node is a simplification of this worklow :

  • a basic custom node (I developed - with custom credential) to get the last companies dataset update date
  • a native Hubspot node with Hubspot Credential readings recent new or modified companies since this last update date
  • an other more complex custom node that updating a companies dataset in our solution. User need to define a row identifer dataset column, user have to map each dataset column with an input item value (Hubspot company in this case, there can be a lot of them, boring to define for the user), …

After simplification, worklow have only one node :
image

User has less setup to do :

At the same time I took the opportunity to solve another problem: the Hubspot API “Get recently modified and created companies” does not return the properties labels of type “enumeration”, so this node is doing other Hubspot API calls (Get all company properties, Get owners, …) to convert codes into labels.

In summary, this simplified node has the disadvantage of being very specific, but has the advantage of simplifying the interaction between the two solutions.

To makes API calls to Hubspot and to our solution with the correct credential, the “execute” method use this functions :

/**
 * Make an API request to Hubspot
 */
export async function hubspotApiRequest(
	this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
	method: IHttpRequestMethods,
	endpoint: string,
	body: IDataObject | GenericValue | GenericValue[] = {},
	query: IDataObject = {},
) {
	const options: IHttpRequestOptions = {
		method,
		body,
		qs: query,
		url: `https://api.hubapi.com/${endpoint}`,
		headers: {
			'content-type': 'application/json; charset=utf-8',
		},
	};

	return this.helpers.httpRequestWithAuthentication.call(this, 'hubspotAppToken', options);
}

/**
 * Make an API request to Geoptis Solution
 */
export async function geoptisSolutionApiRequest(
	this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
	method: IHttpRequestMethods,
	endpoint: string,
	body: IDataObject | GenericValue | GenericValue[] = {},
	query: IDataObject = {},
) {
	const credentials = await this.getCredentials('geoptisSolutionApi');

	const options: IHttpRequestOptions = {
		method,
		body,
		qs: query,
		url: `https://${credentials.host}/api/v1/${endpoint}`,
		headers: {
			'content-type': 'application/json; charset=utf-8',
		},
	};

	return this.helpers.httpRequestWithAuthentication.call(this, 'geoptisSolutionApi', options);
}

You are not getting the credential for the Hubspot call… Could it just be that you have missed that which is why it isn’t working?