Set filepath of created folder/file in OneDrive

Copper Contributor

Hi there, this is INCREDIBLY basic so please forgive my ignorance but:

How can I modify the filepath for a POST request through MS Graph to write a file/folder to OneDrive?

At present the below will write to the root directory of OneDrive:

"name": "Foo",
"folder": {}

However, how would I make create a folder in a path such as "Documents\Foo"?

I've just been playing around with it in Graph Explorer but can't work it out.



1 Reply

I really don't know if this could be the same or maybe I am completely wrong, but some time ago I needed to do the same with the email inbox. I needed to create a subfolder inside the inbox/root folder. After some digging I found out, I needed the fetch the ID of the root folder first before I could create a subfolder

A part of the blog ( I still need to publish :( )

Most of the script was already published on the internet but I needed it to create a subfolder inside the inbox not in the root of the mailbox. So I changed some parts. Let’s break down what I changed:

To create a subfolder inside the Inbox folder, you will need to ID of the inbox folder. Otherwise it does not work.

$Mailboxfolders = Invoke-RestMethod -Uri $Uri -Headers $Header -Method Get -ContentType "application/json"
$mailboxinboxid = $

Now we have the inbox ID we can change the URI were the subfolder need to be created