Al A
Al A

Reputation: 13

how to create a folder using http REST msgraph api

I would like to create a folder on onedrive using msgraph api. I'm posting to "/drive/root" with the following json body

{"name":"hello","folder": {  "childCount": 0  }, }

Here is the error I get. What am I doing wrong?

[{
  "error": {
    "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
    "message": "The parameter name does not exist in method GetById.",
    "innerError": {
      "request-id": "12186368-8f5e-4e7a-81d3-09f3401fda17",
      "date": "2016-02-23T15:44:54"
    }
  }
}
, 400, Bad Request]

Upvotes: 1

Views: 396

Answers (2)

Tobbin2
Tobbin2

Reputation: 105

Finally found a solution that helped me, hopes this works for you too: (post method)

https://graph.microsoft.com/v1.0/groups/${groupId}/drive/items/root:/${ChannelName}:/children

creates it at the root folder, don't forget the ":". Took me 3 days, went inside the wall :/

Upvotes: 0

Marek Rycharski
Marek Rycharski

Reputation: 1694

Please POST to the children collection of the parent folder - e.g. POST "/drive/root/children" or POST "/me/drive/root/children".

Upvotes: 2

Related Questions