mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
Fixed GET method 400 response
This commit is contained in:
parent
9ac9ff3557
commit
aca8441164
|
@ -76,7 +76,7 @@ export class AgileCrm implements INodeType {
|
|||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
|
||||
const endpoint = `api/contacts/${contactId}`;
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint);
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {});
|
||||
|
||||
}
|
||||
|
||||
|
@ -85,11 +85,11 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
if (returnAll) {
|
||||
const endpoint = `api/contacts`;
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint);
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {});
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
const endpoint = `api/contacts?page_size=${limit}`;
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint);
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,17 +14,14 @@ import {
|
|||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> {
|
||||
export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query: IDataObject = {}, uri?: string): Promise<any> {
|
||||
|
||||
const node = this.getNodeParameter('credentials', 1);
|
||||
const credentials = this.getCredentials('agileCrmApi');
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
method,
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: body! || {},
|
||||
auth: {
|
||||
username: credentials!.email as string,
|
||||
password: credentials!.apiKey as string
|
||||
|
@ -33,6 +30,12 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
|
|||
json: true
|
||||
};
|
||||
|
||||
// Only add Body property if method not GET to avoid 400 response
|
||||
if(method !== "GET"){
|
||||
options.body = body;
|
||||
}
|
||||
|
||||
console.log(options);
|
||||
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"n8n": {
|
||||
"credentials": [
|
||||
"dist/credentials/ActiveCampaignApi.credentials.js",
|
||||
"dist/credentials/AgileCrm.credentials.js",
|
||||
"dist/credentials/AgileCrmApi.credentials.js",
|
||||
"dist/credentials/AcuitySchedulingApi.credentials.js",
|
||||
"dist/credentials/AirtableApi.credentials.js",
|
||||
"dist/credentials/Amqp.credentials.js",
|
||||
|
|
Loading…
Reference in a new issue