Skip to content

DriveItem copy.post() returns DriveItem instead of progress URL #1628

Open

Description

@jlayt

Describe the bug

I want to monitor a long-running drive copy job to take action upon completion. The MS Graph API docs state the copy post call returns the monitor URL (see https://learn.microsoft.com/en-us/graph/api/driveitem-copy and https://learn.microsoft.com/en-us/graph/long-running-actions-overview) but the SDK returns an Optional(DriveItem) instead which is always None.

See

async def post(self,body: CopyPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[DriveItem]:

Expected behavior

Returns the progress URL instead of the DriveItem / None

How to reproduce

body = CopyPostRequestBody(
        parent_reference = ItemReference(
        path = "new/path",
    ),
)
result = await graph_client.drives.by_drive_id(drive_id).items.by_drive_item_id(item_id).copy.post(body)
pprint(result)

Other information

This is apparently due to a bug somewhere in the graph definitions, see the DotNet bug report for more details (microsoftgraph/msgraph-sdk-dotnet#2240).

While we wait for this to be fixed (3 years at least and no progress yet!), could you please document here a workaround so googling at least returns something helpful in Python?

Activity

  1. added
    status:waiting-for-triage
    type:bug
    on Nov 20, 2026
  2. jlayt commented on Nov 20, 2026

    @jlayt
    Author

    OK, after much trawling of the internet, i figured out how to use the NativeResponseHeader solution from the DotNet report to get the HTTPX response object and use the returned location header from that.

    from kiota_abstractions.base_request_configuration import RequestConfiguration
    from kiota_abstractions.native_response_handler import NativeResponseHandler
    from kiota_http.middleware.options import ResponseHandlerOption
    
    body = CopyPostRequestBody(
            parent_reference = ItemReference(
            path = "new/path",
        ),
    )
    rc = RequestConfiguration(options=[ResponseHandlerOption(NativeResponseHandler())])
    result = await graph_client.drives.by_drive_id(drive_id).items.by_drive_item_id(item_id).copy.post(body, request_configuration=rc)
    location = result.headers['location']
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:waiting-for-triagetype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions