From 31dd9591097d46adc99728de8c40ab8fb5f2df3d Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Fri, 7 May 2021 19:54:40 -0400 Subject: [PATCH] :bug: Select base url depending on the datacenter (#1744) --- .../credentials/ZohoOAuth2Api.credentials.ts | 2 +- packages/nodes-base/nodes/Zoho/GenericFunctions.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/credentials/ZohoOAuth2Api.credentials.ts b/packages/nodes-base/credentials/ZohoOAuth2Api.credentials.ts index 53372b603b..d9fedc56fe 100644 --- a/packages/nodes-base/credentials/ZohoOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/ZohoOAuth2Api.credentials.ts @@ -53,7 +53,7 @@ export class ZohoOAuth2Api implements ICredentialType { }, { name: 'CN - https://accounts.zoho.com.cn/oauth/v2/token', - value: ' https://accounts.zoho.com.cn/oauth/v2/token', + value: 'https://accounts.zoho.com.cn/oauth/v2/token', }, ], default: 'https://accounts.zoho.com/oauth/v2/token', diff --git a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts index d21c84a9a3..d5e07a3877 100644 --- a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts @@ -1,4 +1,7 @@ -import { OptionsWithUri } from 'request'; +import { + OptionsWithUri, +} from 'request'; + import { IExecuteFunctions, IExecuteSingleFunctions, @@ -9,6 +12,8 @@ import { } from 'n8n-workflow'; export async function zohoApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any + const { oauthTokenData: { api_domain } } = this.getCredentials('zohoOAuth2Api') as { [key: string]: IDataObject }; + const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -20,7 +25,7 @@ export async function zohoApiRequest(this: IExecuteFunctions | IExecuteSingleFun ], }, qs, - uri: uri || `https://www.zohoapis.com/crm/v2${resource}`, + uri: uri || `${api_domain}/crm/v2${resource}`, json: true, }; try { @@ -31,7 +36,7 @@ export async function zohoApiRequest(this: IExecuteFunctions | IExecuteSingleFun } } -export async function zohoApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function zohoApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; @@ -51,4 +56,4 @@ export async function zohoApiRequestAllItems(this: IExecuteFunctions | ILoadOpti ); return returnData; -} +} \ No newline at end of file