Hi Cyrus Majidy,
Hope you are doing well.
As per the documentation, I am able to move the file to other folder using the MS Graph API: PATCH /drives/{drive-id}/items/{item-id}.
with request body:
{
"parentReference": {
"id": "{new-parent-folder-id}"
},
"name": "new-item-name.txt"
}
After successful execution of above graph call, file has been moved to below new location.
And also, I am able to open this moved file from new location without any issue.
Drive
is the top-level object that represents a user's OneDrive or a document library in SharePoint.
driveId
is the unique identifier of the drive.
itemId
is the unique identifier of the file or folder.
There are two endpoints you can use.
If you want to move file to another folder but between the same drive (document library) you can use
PATCH /drives/{drive-id}/items/{item-id}
with request body.
{
"parentReference": {
"id": "{new-parent-folder-id}"
},
"name": "new-item-name.txt"
}
drive-id
is the id of the source drive.
item-id
is the id of the file you want to move.
new-parent-folder-id
is the id of the destination folder.
If you want to move file between two drive (document libraries) you can use
POST /drives/{driveId}/items/{itemId}/copy
with request body
{
"parentReference": {
"driveId": "{new-drive-id}",
"id": "{new-parent-folder-id}"
},
"name": "new-item-name.txt"
}
drive-id
is the id of the source drive.
item-id
is the id of the file you want to move.
new-drive-id
is the id of the destination drive.
new-parent-folder-id
is the id of the destination folder.
Reference links:
Resources:
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.