diff --git a/packages/nodes-base/credentials/HubspotApi.credentials.ts b/packages/nodes-base/credentials/HubspotApi.credentials.ts index 1a1906692f43e..bda8e42b97f24 100644 --- a/packages/nodes-base/credentials/HubspotApi.credentials.ts +++ b/packages/nodes-base/credentials/HubspotApi.credentials.ts @@ -1,4 +1,4 @@ -import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow'; +import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow'; export class HubspotApi implements ICredentialType { name = 'hubspotApi'; @@ -21,4 +21,11 @@ export class HubspotApi implements ICredentialType { }, }, }; + + test: ICredentialTestRequest = { + request: { + baseURL: 'https://api.hubapi.com', + url: '/account-info/v3/details', + }, + }; } diff --git a/packages/nodes-base/credentials/HubspotAppToken.credentials.ts b/packages/nodes-base/credentials/HubspotAppToken.credentials.ts index 9e95f83034deb..0bd7ffda436c6 100644 --- a/packages/nodes-base/credentials/HubspotAppToken.credentials.ts +++ b/packages/nodes-base/credentials/HubspotAppToken.credentials.ts @@ -1,4 +1,4 @@ -import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow'; +import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow'; export class HubspotAppToken implements ICredentialType { name = 'hubspotAppToken'; @@ -21,4 +21,11 @@ export class HubspotAppToken implements ICredentialType { }, }, }; + + test: ICredentialTestRequest = { + request: { + baseURL: 'https://api.hubapi.com', + url: '/account-info/v3/details', + }, + }; } diff --git a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts index eda2a56575b18..acc2b3cd3a9ac 100644 --- a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts @@ -38,10 +38,8 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions }; try { - if (authenticationMethod === 'apiKey') { - return this.helpers.requestWithAuthentication.call(this, 'hubspotApi', options); - } else if (authenticationMethod === 'appToken') { - return this.helpers.requestWithAuthentication.call(this, 'hubspotAppToken', options); + if (authenticationMethod === 'apiKey' || authenticationMethod === 'appToken') { + return this.helpers.requestWithAuthentication.call(this, authenticationMethod, options); } else if (authenticationMethod === 'developerApi') { if (endpoint.includes('webhooks')) {