So I'm quite a fan of the Graph API to manage Onedrive from my server. Now I'm trying to use the Graph API to move a file from one directory to another one following the documentation here.
Now in order to do so, I send (PATCH) the following to https://graph.microsoft.com/v1.0/me/drive/items/01A2ASUEXPG7EKMCTPDJDY7L5YMVTNWHMO:
{'parentReference': {'id': '01A2ASUEVXTMODEW6HIJC3MSXT5JJ4JLRK'}}
And I receive:
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('b9dc908f-6c6f-463b-a568-9361fabdc995')/drive/items/$entity",
"@microsoft.graph.downloadUrl":"xxxx",
"createdDateTime":"2022-04-20T08:46:12Z",
"eTag":"\"{A6C837EF-6F0A-471A-8FAF-B86566DB1D8E},1\"",
"id":"01A2ASUEXPG7EKMCTPDJDY7L5YMVTNWHMO",
"lastModifiedDateTime":"2022-04-20T08:46:12Z",
"name":"IMG.png",
"webUrl":"https://xxxx-my.sharepoint.com/personal/xxxx-uitzendbureau_nl/Documents/Loonstroken%20(alleen%20voor%20toevoegen)/xxxx/IMG.png",
"cTag":"\"c:{A6C837EF-6F0A-471A-8FAF-B86566DB1D8E},1\"",
"size":382692,
"createdBy":{
"user":{
"email":"[email protected]",
"id":"b9dc908f-6c6f-463b-a568-9361fabdc995",
"displayName":"Online beheer"
}
},
"lastModifiedBy":{
"user":{
"email":"[email protected]",
"id":"b9dc908f-6c6f-463b-a568-9361fabdc995",
"displayName":"Online beheer"
}
},
"parentReference":{
"driveType":"business",
"driveId":"b!u2WpOb6qnkS_6foMbPUq90TwxghBinBMhj9DwokQnQefs7rIOSQYS5kmJNV5uSJ7",
"id":"01A2ASUEWGZQX5GCGE2RFL6J3WBIW2LTUC",
"path":"/drive/root:/Loonstroken (alleen voor toevoegen)/xxxxxx"
},
"file":{
"mimeType":"image/png",
"hashes":{
"quickXorHash":"Yk0eRqT2ThqJHamo0AMLstI0CBI="
}
},
"fileSystemInfo":{
"createdDateTime":"2022-04-20T08:46:12Z",
"lastModifiedDateTime":"2022-04-20T08:46:12Z"
},
"image":{
},
"shared":{
"scope":"users"
}
}
As you can see:
'parentReference': {'driveType': 'business', 'driveId': 'xxx', 'id': '01A2ASUEWGZQX5GCGE2RFL6J3WBIW2LTUC', 'path': '/drive/root:/Loonstroken (alleen voor toevoegen)/xxxxxx'}
The parentReference ID has not changed to the one provided in the request, but still a 200 is returned. Also the file obviously was not moved.
Any idea what might be the issue here?
Answering my own question.
Seems this was an issue on Microsoft's end. I now get a correct parentReference in the response.