mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08: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:
parent
5a0e356ab6
commit
d64c767ebd
|
@ -36,11 +36,11 @@ export class PagerDutyOAuth2Api implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Authentication',
|
displayName: 'Authentication',
|
||||||
name: 'authentication',
|
name: 'authentication',
|
||||||
type: 'hidden' as NodePropertyTypes,
|
type: 'hidden' as NodePropertyTypes,
|
||||||
default: 'header',
|
default: 'header',
|
||||||
description: 'Method of authentication.',
|
description: 'Method of authentication.',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,5 +37,12 @@ export class SalesforceOAuth2Api implements ICredentialType {
|
||||||
type: 'hidden' as NodePropertyTypes,
|
type: 'hidden' as NodePropertyTypes,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Authentication',
|
||||||
|
name: 'authentication',
|
||||||
|
type: 'hidden' as NodePropertyTypes,
|
||||||
|
default: 'header',
|
||||||
|
description: 'Method of authentication.',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
import { OptionsWithUri } from 'request';
|
import {
|
||||||
|
OptionsWithUri,
|
||||||
|
} from 'request';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
IExecuteSingleFunctions,
|
IExecuteSingleFunctions,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject
|
IDataObject
|
||||||
} from 'n8n-workflow';
|
} 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 credentials = this.getCredentials('salesforceOAuth2Api');
|
||||||
const subdomain = ((credentials!.accessTokenUrl as string).match(/https:\/\/(.+).salesforce\.com/) || [])[1];
|
const subdomain = ((credentials!.accessTokenUrl as string).match(/https:\/\/(.+).salesforce\.com/) || [])[1];
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
method,
|
method,
|
||||||
body: method === "GET" ? undefined : body,
|
body: method === "GET" ? undefined : body,
|
||||||
qs,
|
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
|
json: true
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
@ -39,7 +43,7 @@ export async function salesforceApiRequestAllItems(this: IExecuteFunctions | ILo
|
||||||
|
|
||||||
do {
|
do {
|
||||||
responseData = await salesforceApiRequest.call(this, method, endpoint, body, query, uri);
|
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]);
|
returnData.push.apply(returnData, responseData[propertyName]);
|
||||||
} while (
|
} while (
|
||||||
responseData.nextRecordsUrl !== undefined &&
|
responseData.nextRecordsUrl !== undefined &&
|
||||||
|
|
|
@ -15,66 +15,84 @@ import {
|
||||||
accountFields,
|
accountFields,
|
||||||
accountOperations,
|
accountOperations,
|
||||||
} from './AccountDescription';
|
} from './AccountDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IAccount,
|
IAccount,
|
||||||
} from './AccountInterface';
|
} from './AccountInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
attachmentFields,
|
attachmentFields,
|
||||||
attachmentOperations,
|
attachmentOperations,
|
||||||
} from './AttachmentDescription';
|
} from './AttachmentDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IAttachment,
|
IAttachment,
|
||||||
} from './AttachmentInterface';
|
} from './AttachmentInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICampaignMember,
|
ICampaignMember,
|
||||||
} from './CampaignMemberInterface';
|
} from './CampaignMemberInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
caseFields,
|
caseFields,
|
||||||
caseOperations,
|
caseOperations,
|
||||||
} from './CaseDescription';
|
} from './CaseDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICase,
|
ICase,
|
||||||
ICaseComment,
|
ICaseComment,
|
||||||
} from './CaseInterface';
|
} from './CaseInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
contactFields,
|
contactFields,
|
||||||
contactOperations,
|
contactOperations,
|
||||||
} from './ContactDescription';
|
} from './ContactDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IContact,
|
IContact,
|
||||||
} from './ContactInterface';
|
} from './ContactInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
salesforceApiRequest,
|
salesforceApiRequest,
|
||||||
salesforceApiRequestAllItems,
|
salesforceApiRequestAllItems,
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
leadFields,
|
leadFields,
|
||||||
leadOperations,
|
leadOperations,
|
||||||
} from './LeadDescription';
|
} from './LeadDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ILead,
|
ILead,
|
||||||
} from './LeadInterface';
|
} from './LeadInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
INote,
|
INote,
|
||||||
} from './NoteInterface';
|
} from './NoteInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
opportunityFields,
|
opportunityFields,
|
||||||
opportunityOperations,
|
opportunityOperations,
|
||||||
} from './OpportunityDescription';
|
} from './OpportunityDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IOpportunity,
|
IOpportunity,
|
||||||
} from './OpportunityInterface';
|
} from './OpportunityInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
taskFields,
|
taskFields,
|
||||||
taskOperations,
|
taskOperations,
|
||||||
} from './TaskDescription';
|
} from './TaskDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ITask,
|
ITask,
|
||||||
} from './TaskInterface';
|
} from './TaskInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
userFields,
|
userFields,
|
||||||
userOperations,
|
userOperations,
|
||||||
} from './UserDescription';
|
} from './UserDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IUser,
|
IUser,
|
||||||
} from './UserInterface';
|
} from './UserInterface';
|
||||||
|
|
Loading…
Reference in a new issue