Reputation: 2005
I have the app that uses MS graph API for onedrive . When i try to move a file to root of a drive from some folder i have an error "One of the provided arguments is not acceptable".
But same code works fine for "individual" onedrive accounts, problem is only for OneDrive for business accounts. Also, move to any other folder works fine.
I am sending PATCH request o move a file.
For free onedrive the request body looks like
(
[parentReference] =>
(
[path] => //drives/68XXXXX7f7f7d7c/root
)
)
this works. but same code for oneDrive for business fails
(
[parentReference] =>
(
[path] => //drives/b!-0dIs3JX..TRUNCATED...0_oR2A...L0PY/root
)
)
This gives error "One of the provided arguments is not acceptable"
What can this be? Any ideas? I follow the docs here https://learn.microsoft.com/en-us/graph/api/driveitem-move?view=graph-rest-1.0
Upvotes: 1
Views: 915
Reputation: 33094
This issue is noted in the documentation:
Note: When moving items to the root of a drive your app cannot use the
"id:" "root"
syntax. Your app needs to provide the actual ID of the root folder for the parent reference.
To retrieve the actual id, you need to retrieve the id
from the root
object:
/drives/{drive-id}/root
This will return something along the lines of this:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/drive/root/$entity",
"createdDateTime": "2017-07-27T02:41:36Z",
"id": "01BYE5RZ56Y2GOVW7725BZO354PWSELRRZ",
"lastModifiedDateTime": "2019-01-18T03:41:15Z",
"name": "root",
"webUrl": "https://m365x214355-my.sharepoint.com/personal/meganb_m365x214355_onmicrosoft_com/Documents",
"size": 106330475,
"parentReference": {
"driveId": "b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd",
"driveType": "business"
},
"fileSystemInfo": {
"createdDateTime": "2017-07-27T02:41:36Z",
"lastModifiedDateTime": "2019-01-18T03:41:15Z"
},
"folder": {
"childCount": 38
},
"root": {}
}
Using the above example, when moving the file, your path would be:
/drives/b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd/01BYE5RZ56Y2GOVW7725BZO354PWSELRRZ
Upvotes: 1