From 230e3f8209217aea3fc02c8ac2d4bdf626d2a758 Mon Sep 17 00:00:00 2001 From: ricardo Date: Fri, 3 Apr 2020 11:19:35 -0400 Subject: [PATCH] :zap: Added subfolders --- .../Microsoft/OneDrive/FolderDescription.ts | 26 +++++++++++++++++++ .../OneDrive/MicrosoftOneDrive.node.ts | 7 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts index 62f488ae0c..55401bee5f 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts @@ -57,6 +57,32 @@ export const folderFields = [ default: '', description: `Folder's name`, }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'folder', + ], + }, + }, + default: {}, + placeholder: 'Add Field', + options: [ + { + displayName: 'Parent Folder ID', + name: 'parentFolderId', + type: 'string', + default: '', + description: 'ID of the folder you want to crate the new folder in', + }, + ], + }, /* -------------------------------------------------------------------------- */ /* folder:getChildren */ /* -------------------------------------------------------------------------- */ diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts index 2af523cbc0..8b65b6b99f 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts @@ -196,11 +196,16 @@ export class MicrosoftOneDrive implements INodeType { //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 options = this.getNodeParameter('options', i) as IDataObject; const body: IDataObject = { name, folder: {}, }; - responseData = await microsoftApiRequest.call(this, 'POST', '/drive/root/children', body); + let endpoint = '/drive/root/children'; + if (options.parentFolderId) { + endpoint = `/drive/items/${options.parentFolderId}/children`; + } + responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body); returnData.push(responseData); } //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online