From 148a94a8bb22f8aa589453da3a5f4489c8f94762 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Fri, 12 Mar 2021 04:23:35 -0500 Subject: [PATCH] :bug: Fix bug when updating and deleting records (#1532) --- .../nodes/Airtable/Airtable.node.ts | 25 +++++++++---------- .../nodes/Airtable/GenericFunctions.ts | 1 + 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/nodes-base/nodes/Airtable/Airtable.node.ts b/packages/nodes-base/nodes/Airtable/Airtable.node.ts index 4f15041474..62dc8a47fc 100644 --- a/packages/nodes-base/nodes/Airtable/Airtable.node.ts +++ b/packages/nodes-base/nodes/Airtable/Airtable.node.ts @@ -137,7 +137,7 @@ export class Airtable implements INodeType { // delete // ---------------------------------- { - displayName: 'Id', + displayName: 'ID', name: 'id', type: 'string', displayOptions: { @@ -317,7 +317,7 @@ export class Airtable implements INodeType { // read // ---------------------------------- { - displayName: 'Id', + displayName: 'ID', name: 'id', type: 'string', displayOptions: { @@ -336,7 +336,7 @@ export class Airtable implements INodeType { // update // ---------------------------------- { - displayName: 'Id', + displayName: 'ID', name: 'id', type: 'string', displayOptions: { @@ -499,7 +499,7 @@ export class Airtable implements INodeType { for (let i = 0; i < items.length; i++) { id = this.getNodeParameter('id', i) as string; - endpoint = `${application}/${table}/${id}`; + endpoint = `${application}/${table}`; // Make one request after another. This is slower but makes // sure that we do not run into the rate limit they have in @@ -507,9 +507,11 @@ export class Airtable implements INodeType { // functionality in core should make it easy to make requests // according to specific rules like not more than 5 requests // per seconds. + qs.records = [id]; + responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - returnData.push(responseData); + returnData.push(...responseData.records); } } else if (operation === 'list') { @@ -586,7 +588,6 @@ export class Airtable implements INodeType { let updateAllFields: boolean; let fields: string[]; let options: IDataObject; - for (let i = 0; i < items.length; i++) { updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean; options = this.getNodeParameter('options', i, {}) as IDataObject; @@ -616,13 +617,9 @@ export class Airtable implements INodeType { } } - if (options.typecast === true) { - body['typecast'] = true; - } - id = this.getNodeParameter('id', i) as string; - endpoint = `${application}/${table}/${id}`; + endpoint = `${application}/${table}`; // Make one request after another. This is slower but makes // sure that we do not run into the rate limit they have in @@ -631,9 +628,11 @@ export class Airtable implements INodeType { // according to specific rules like not more than 5 requests // per seconds. - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + const data = { records: [{ id, fields: body.fields }], typecast: (options.typecast) ? true : false }; - returnData.push(responseData); + responseData = await apiRequest.call(this, requestMethod, endpoint, data, qs); + + returnData.push(...responseData.records); } } else { diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index d13b3a5723..9fbcd5785d 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -58,6 +58,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa body, qs: query, uri: uri || `https://api.airtable.com/v0/${endpoint}`, + useQuerystring: false, json: true, };