Graph API - Sharepoint copyItem with parentReference not working

Nobilex 46 Reputation points

Hello everyone,


This API of copy drive item using graph api version 2.3.2 was working fine and since morning without any code change we are facing an issue. It seems that even if we pass parentReference, still it's copying into same directory as source file.

We are copying file from one folder to another folder with new path and name using graph API and kotlin

.copy(it.newPath.getFilename(), parentReference)

Above code was working till 18th-April-2022 and not working since 19th-April-2022 morning. It is copying file in same directory as source file instead of copying into new location. We are using msgraph-sdk-java

Can someone look into it and revert?

Microsoft Graph Groups API
Microsoft Graph Groups API
A Microsoft API that creates and manages different types of groups and group functionality.
204 questions
Microsoft Graph Files API
Microsoft Graph Files API
A Microsoft API to create an app that connects with files across OneDrive, OneDrive for Business, and SharePoint document libraries.
355 questions
Microsoft Graph SDK
Microsoft Graph SDK
A Microsoft software developer kit designed to simplify building high-quality, efficient, and resilient applications that access Microsoft Graph.
891 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,466 Reputation points

    Hi @Nobilex ,

    I am able to reproduce this issue and there is a open case with Microsoft Engineering team for the driveitem-copy into same location.

    Will keep you informed about the progress.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".

    4 people found this answer helpful.

  2. Praveen Narala 21 Reputation points

    @SrinivasaRaoDarnaMSFT-7657 Hi Srinivas, we are having the same issue while coping with the drive item from one folder to another folder. It is blocking our current release checks. Would be appreciated if this gets sorted ASAP. Thanks.

    2 people found this answer helpful.

  3. Curzio Carabelli 6 Reputation points

    The issue seems to have been fixed. I am again able to move files across folders through the Graph API by quoting the parentReference item Id

  4. Nobilex 46 Reputation points

    For temporary workaround if we pass path of parentReference along with Id then it's working fine. (ref:

    fun main() {  
        val graphClient: GraphServiceClient<*> = GraphServiceClient  
        //Trigger copy operation with parent reference  
        val targetDirectory = ItemReference()  = "XXX"  
        targetDirectory.path = "XXX" // If we pass path for target directory item reference then it's working fine but with just id of target directory it will not work until they don't resolve it.