Skip to content

OneDrive/SharePoint — Create folder

Type: msfiles-create-folder  ·  Package: OneDrive / SharePoint v1.0.5  ·  Output: Dictionary<string,object>

Creates a folder in the drive and returns its data (including the ID), which you will usually use as the target when uploading or moving files.

It works on the session created with OneDrive/SharePoint — Connect. Pass it in the session parameter, or place this activity inside the body of Connect to inherit it automatically.

If you do not give folderId, the folder is created at the drive root. To nest it, pass the parent folder’s ID.

ParameterTypeDefaultDescription
namestring—Folder name. Without characters not allowed in OneDrive/SharePoint (" * : < > ? / \ |).
ParameterTypeDefaultDescription
sessionZoanMicrosoftFilesSession—Connect session. Inherited inside Connect’s body.
folderIdstring—Parent folder ID. When omitted, the drive root.

Returns a Dictionary<string,object> with the created folder’s data: id, name (the final name, which may carry a number if it already existed), isFolder (true), size, webUrl, parentId, modifiedTime, createdTime and childCount (0). Use folder["id"] as the target folderId in Move, Copy or when creating subfolders.

MessageCause and fix
No OneDrive/SharePoint session available. Provide 'session' from an msfiles-connect activity, or place this activity inside the Connect activity's body so the session is inherited automatically.The activity is outside Connect’s body and did not receive session. Place it inside the body or pass session = session.
'name' is required.name is empty or its expression returned null.
itemNotFound (Microsoft Graph, 404)There is no parent folder with that folderId.
invalidRequest (Microsoft Graph, 400)The name has characters that are not allowed.
Folder creation returned no item.Microsoft Graph replied without the folder data. Check with List files whether it was created before retrying.
OneDrive/SharePoint — Connect credential = credential("m365-operations")
└─ body:
OneDrive/SharePoint — Create folder name = "Reports " + DateTime.Now.ToString("yyyy-MM") → output: folder
OneDrive/SharePoint — Move id = reportId folderId = folder["id"]