Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DriveItem Copy endpoint has incorrect return type #2240

Closed
hazzinator1 opened this issue Dec 4, 2023 · 1 comment
Closed

DriveItem Copy endpoint has incorrect return type #2240

hazzinator1 opened this issue Dec 4, 2023 · 1 comment

Comments

@hazzinator1
Copy link

Describe the bug
The current implementation of Copy endpoint for drive items is incorrect, as it tries to return a DriveItem as the result. The Graph API documentation shows that it instead sends back a URI in the Location response header.
#768 seemed to show that it was possible to access the response headers, however this ability is either hidden to me or has been changed and is therefore no longer accessible.

To Reproduce

var copyResponse = this.GraphServiceClient
                .Drives[driveId]
                .Items[driveItemId]
                .Copy.PostAsync(copyRequestBody);

Expected behavior
Rather than trying to find "workarounds" to get the Location URI, why can't the Copy method just return the URI as the result?

No other relevant information

@hazzinator1 hazzinator1 changed the title DriveItem Copy endpoint does not work DriveItem Copy endpoint has incorrect return type Dec 4, 2023
@andrueastman
Copy link
Member

Thanks for raising this @hazzinator1

At the moment this is possible to do as below.
https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/upgrade-to-v5.md#native-response-object

            var nativeResponseHandler = new NativeResponseHandler();
            await graphClient.Drives["drive-id"]
                .Items["item-id"]
                .Copy.PostAsync(copyRequestBody,
                    requestConfiguration => requestConfiguration.Options.Add(new ResponseHandlerOption
                        { ResponseHandler = nativeResponseHandler }));

            var responseMessage = nativeResponseHandler.Value as HttpResponseMessage;
            var locationheader = responseMessage.Headers.Location.OriginalString;

As this falls under the polling of long running operations, this work is currently pending the resolution of microsoftgraph/msgraph-sdk-design#83. We'll close this issue for now to be tracked via #1366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants