diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts index cead016ab4..62f488ae0c 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts @@ -13,6 +13,11 @@ export const folderOperations = [ }, }, options: [ + { + name: 'Create', + value: 'create', + description: 'Create a folder', + }, { name: 'Get Children', value: 'getChildren', @@ -31,6 +36,27 @@ export const folderOperations = [ export const folderFields = [ +/* -------------------------------------------------------------------------- */ +/* folder:create */ +/* -------------------------------------------------------------------------- */ + { + displayName: 'Name', + name: 'name', + required: true, + type: 'string', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'folder', + ], + }, + }, + default: '', + description: `Folder's name`, + }, /* -------------------------------------------------------------------------- */ /* folder:getChildren */ /* -------------------------------------------------------------------------- */ diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts index 9330437f77..1bd1bee202 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts @@ -33,6 +33,7 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing if (Object.keys(body).length === 0) { delete options.body; } + //@ts-ignore return await this.helpers.requestOAuth.call(this, 'microsoftOneDriveOAuth2Api', options); } catch (error) { diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts index 199dd48798..2af523cbc0 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts @@ -193,6 +193,16 @@ export class MicrosoftOneDrive implements INodeType { } } if (resource === 'folder') { + //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online + if (operation === 'create') { + const name = this.getNodeParameter('name', i) as string; + const body: IDataObject = { + name, + folder: {}, + }; + responseData = await microsoftApiRequest.call(this, 'POST', '/drive/root/children', body); + returnData.push(responseData); + } //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online if (operation === 'getChildren') { const folderId = this.getNodeParameter('folderId', i) as string;