mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
Salesforce (#932)
* fix salesforce error while get all using nextRecordsUrl The uri for using nextRecordsUrl to get all data in salesforce node is error. The right usage is fixed in this pr. * ⚡ Small changes * :zap Small fix Co-authored-by: YErii <yeriime@outlook.com> Co-authored-by: Jan <janober@users.noreply.github.com>
This commit is contained in:
@@ -1,21 +1,25 @@
|
||||
import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function salesforceApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function salesforceApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('salesforceOAuth2Api');
|
||||
const subdomain = ((credentials!.accessTokenUrl as string).match(/https:\/\/(.+).salesforce\.com/) || [])[1];
|
||||
const options: OptionsWithUri = {
|
||||
method,
|
||||
body: method === "GET" ? undefined : body,
|
||||
qs,
|
||||
uri: uri || `https://${subdomain}.salesforce.com/services/data/v39.0${resource}`,
|
||||
uri: `https://${subdomain}.salesforce.com/services/data/v39.0${uri || endpoint}`,
|
||||
json: true
|
||||
};
|
||||
try {
|
||||
@@ -39,7 +43,7 @@ export async function salesforceApiRequestAllItems(this: IExecuteFunctions | ILo
|
||||
|
||||
do {
|
||||
responseData = await salesforceApiRequest.call(this, method, endpoint, body, query, uri);
|
||||
uri = responseData.nextRecordsUrl;
|
||||
uri = `${endpoint}/${responseData.nextRecordsUrl?.split('/')?.pop()}`;
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData.nextRecordsUrl !== undefined &&
|
||||
|
||||
Reference in New Issue
Block a user