1

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]

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

6 Comments

thank you @MarekRycharski for your response. Now I get the following. I know my access token is valid because I can call other APIs with it like getting list of files etc.... <br/> [{ "error": { "code": "unauthenticated", "message": "The caller is not authenticated.", "innerError": { "request-id": "362c0cf7-c73a-4413-b9c0-b3d74bd6d290", "date": "2016-02-23T19:56:50" } } } , 401, Unauthorized]
Your token had Files.Read scope, which is sufficient for read operations, but for writes you need Files.ReadWrite. Please configure that delegated permission for your application.
thanks @MarekRycharski strange because when I registered my app I gave it Files.readwrite. BTW this is a trial account could that be the reason?
here is my permissions list <br/>•Sign you in and read your profile •Have full access to your files and files shared with you •Read your files and files shared with you •Have full access of your contacts •Read your contacts •Have full access to your calendars •Read your calendars •Send mail as you •Read and write access to your mail •Read your mail •Read and write all groups •Read all groups •Read and write all users' full profiles •Read all users' full profiles •Sign you in and read your profile
If you added the added the Files.ReadWrite permission to your app after it was consented you need to re-consent. Please remove its access for the tenant you're using and request a new token to re-consent.
|
0

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 :/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.