diff --git a/packages/nodes-base/nodes/SeaTable/v2/actions/base/apiCall/description.ts b/packages/nodes-base/nodes/SeaTable/v2/actions/base/apiCall/description.ts
index 8e8f36a669..da4f8f0210 100644
--- a/packages/nodes-base/nodes/SeaTable/v2/actions/base/apiCall/description.ts
+++ b/packages/nodes-base/nodes/SeaTable/v2/actions/base/apiCall/description.ts
@@ -1,25 +1,6 @@
import type { BaseProperties } from '../../Interfaces';
export const baseApiCallDescription: BaseProperties = [
- {
- displayName: 'Table Name',
- name: 'tableName',
- type: 'options',
- placeholder: 'Select a table',
- required: true,
- typeOptions: {
- loadOptionsMethod: 'getTableNames',
- },
- displayOptions: {
- show: {
- resource: ['base'],
- operation: ['apiCall'],
- },
- },
- default: '',
- description:
- 'The name of SeaTable table to access. Choose from the list, or specify a name using an expression.',
- },
{
displayName: 'HTTP Method',
name: 'apiMethod',
@@ -34,8 +15,8 @@ export const baseApiCallDescription: BaseProperties = [
value: 'GET',
},
{
- name: 'POST',
- value: 'POST',
+ name: 'PUT',
+ value: 'PUT',
},
{
name: 'DELETE',
@@ -133,4 +114,20 @@ export const baseApiCallDescription: BaseProperties = [
description:
'Only valid JSON is accepted. n8n will pass anything you enter as raw input. For example, {"foo", "bar"} is perfectly valid. Of cause you can use variables from n8n inside your JSON.',
},
+ {
+ displayName: 'Response object parameter name',
+ name: 'responseObjectName',
+ type: 'string',
+ placeholder: 'Leave it empty or use a value like "rows", "metadata", "views" etc.',
+ required: false,
+ displayOptions: {
+ show: {
+ resource: ['base'],
+ operation: ['apiCall'],
+ },
+ },
+ default: '',
+ description:
+ 'When using the SeaTable API, you can specify a parameter to retrieve either the entire array of objects or a specific object within it. This allows you to choose whether to fetch the complete output or only the object related to the provided parameter.',
+ },
];
diff --git a/packages/nodes-base/nodes/SeaTable/v2/actions/base/apiCall/execute.ts b/packages/nodes-base/nodes/SeaTable/v2/actions/base/apiCall/execute.ts
index 8b212b1d87..1a66d6e9dc 100644
--- a/packages/nodes-base/nodes/SeaTable/v2/actions/base/apiCall/execute.ts
+++ b/packages/nodes-base/nodes/SeaTable/v2/actions/base/apiCall/execute.ts
@@ -1,15 +1,40 @@
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import { seaTableApiRequest } from '../../../GenericFunctions';
+import { APITypes } from '../../../types';
export async function apiCall(
this: IExecuteFunctions,
index: number,
): Promise {
+ const apiMethod = this.getNodeParameter('apiMethod', index) as APITypes;
+ const apiEndpoint = this.getNodeParameter('apiEndpoint', index) as APITypes;
+ const responseObjectName = this.getNodeParameter('responseObjectName', index) as string;
+
+ // body params
+ const apiBody = this.getNodeParameter('apiBody', index) as any;
+
+ // query params
+ const apiParams: IDataObject = {};
+ const params = this.getNodeParameter('apiParams.apiParamsValues', index, []) as any;
+ for (const param of params) {
+ apiParams[`${param.key}`] = param.value;
+ }
+ console.log(apiParams);
+
const responseData = await seaTableApiRequest.call(
this,
{},
- 'GET',
- '/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata/',
+ apiMethod,
+ apiEndpoint,
+ apiBody,
+ apiParams,
);
- return this.helpers.returnJsonArray(responseData.metadata as IDataObject[]);
+ console.log(responseData);
+
+ // output
+ if (responseObjectName) {
+ return this.helpers.returnJsonArray(responseData[responseObjectName] as IDataObject[]);
+ } else {
+ return this.helpers.returnJsonArray(responseData as IDataObject[]);
+ }
}
diff --git a/packages/nodes-base/nodes/SeaTable/v2/types.ts b/packages/nodes-base/nodes/SeaTable/v2/types.ts
index db0078d9c5..a61ef2d1e0 100644
--- a/packages/nodes-base/nodes/SeaTable/v2/types.ts
+++ b/packages/nodes-base/nodes/SeaTable/v2/types.ts
@@ -95,3 +95,5 @@ export type TColumnsUiValues = Array<{
columnName: string;
columnValue: string;
}>;
+
+export type APITypes = 'GET' | 'POST' | 'DELETE' | 'PUT';