question

Janet-0749 avatar image
0 Votes"
Janet-0749 asked saldana-msft edited

Microsoft Graph copy sharepoint files item not found and other errors

I am attempting to use Microsoft graph to copy sharepoint files from one folder to one of the subfolders. I followed the syntax that was documented on the Microsoft site. I received the error that the "item was not found" and the I also included the driveid and got the error "item already exists". I was following the instructions provided in https://developer.microsoft.com/en-us/microsoft-365/blogs/microsoft-graph-mailbag-copy-move-files-and-folders-in-sharepoint-online/.

item not found
POST /sites/{siteId}/drive/items/{itemId}/copy
REQUEST BODY
{
"parentReference": {
"driveId": "<driveID>",
"id": "<driveID>"
},
"name": "<filename>"
}

item already exists
POST /sites/{siteId}/drive/{driveid}/items/{itemId}/copy
REQUEST BODY
{
"parentReference": {
"driveId": "<driveID>",
"id": "<driveID>"
},
"name": "<filename>"
}

https://graph.microsoft.com/v1.0/sites/coxcomminc.sharepoint.com,c80fc32c-7057-4cc6-881f-3a1c9ae3c377,fbecb94e-b16f-4be1-ab7b-4e9be34df31f/drive/items/0175UB7YWSAPE26ILFCREL73RWHBRRT3TI/copy

{
"parentReference": {
"driveId": "b!LMMPyFdwxkyIHzocmuPDd0657PtvseFLq3tOm-NN8x_vtqchuBJ2Rr-ZJOA6WIQ8",
"id": "0175UB7YV6Y2GOVW7725BZO354PWSELRRZ"
},
"name": "test.doc"
}
===================================================================
{
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"date": "2021-10-01T12:00:37",
"request-id": "c410b4f9-029e-48e0-bdc9-bf4de4a48973",
"client-request-id": "ad0191db-614c-e3e4-c6e1-fcfa5b7e78c5"
}
}
}

{
"error": {
"code": "nameAlreadyExists",
"message": "The specified item name already exists.",
"innerError": {
"date": "2021-09-30T16:37:18",
"request-id": "57a3dd90-2eaf-4e77-b0e6-50c3b4641584",
"client-request-id": "fc3e1a88-1bea-3820-5241-ed8a46de9ded"
}
}
}

office-sharepoint-onlinemicrosoft-graph-sdk
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Janet-0749 ,
would you please provide us with an update on the status of your issue?

0 Votes 0 ·

@RaytheonXie-MSFT
Unfortunately the solution you provided did not work for me. I received Bad Request - 400. I am assuming that there is something else I am missing when it comes to the syntax.

0 Votes 0 ·

Hi @Janet-0749 ,
The request id should be the folder id of the destination

 {
 "parentReference": {
 "driveId": "<driveid>",
 "id": "<siteid>"
 },
 "name": "<filename>"
 }




0 Votes 0 ·

Hi @Janet-0749 ,
I am checking to see how things are going there on this issue.

0 Votes 0 ·

Hi @Janet-0749 ,
I am checking to see if the problem has been resolved.

0 Votes 0 ·

Hi @Janet-0749 ,
If there's anything you'd like to know, don't hesitate to ask.

0 Votes 0 ·

1 Answer

RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered

Hi @Janet-0749 ,
Per my test, '/drive' set the 'Document' library as default. The url can't get the library of our resource.
We can get our file copyed by following url:

 POST /sites/{siteId}/drives/{drive-id}/items/{itemId}/copy


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.