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

Conflict Behavior cannot be set for Drive Item Copy #1555

Open
JeroenTriptic opened this issue Jul 9, 2024 · 2 comments
Open

Conflict Behavior cannot be set for Drive Item Copy #1555

JeroenTriptic opened this issue Jul 9, 2024 · 2 comments
Labels
dependency:metadata Awaiting fix from core dependency project module type:bug A broken experience

Comments

@JeroenTriptic
Copy link

JeroenTriptic commented Jul 9, 2024

Describe the bug

I try to copy a file from folder A to folder B and I try to use @microsoft.graph.conflictBehavior but the request does not allow query parameters and it doesn't work if I add it to the body.

Expected behavior

I expected CopyRequestBuilderPostRequestConfiguration to have query options. Or for the CopyPostRequestBody->setAdditionalData(['@microsoft.graph.conflictBehavior' => 'rename']) to work.

How to reproduce

<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Drives\Item\Items\Item\Copy\CopyPostRequestBody;
use Microsoft\Graph\Generated\Models\ItemReference;


$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);

$requestBody = new CopyPostRequestBody();
$parentReference = new ItemReference();
$parentReference->setDriveId('6F7D00BF-FC4D-4E62-9769-6AEA81F3A21B');
$parentReference->setId('DCD0D3AD-8989-4F23-A5A2-2C086050513F');
$requestBody->setParentReference($parentReference);
$requestBody->setAdditionalData(['@microsoft.graph.conflictBehavior' => 'rename']);

$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->copy()->post($requestBody)->wait();

When there is already a file in the destination folder with the same name it doesn't do anything instead of renaming the new file.

SDK Version

2.10.0

Latest version known to work for scenario above?

1.110.0

Known Workarounds

No response

Debug output

No response

Configuration

No response

Other information

No response

@JeroenTriptic JeroenTriptic added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jul 9, 2024
@Ndiritu
Copy link
Contributor

Ndiritu commented Jul 12, 2024

Thanks for reporting this @JeroenTriptic.

As a temporary work-around, you can use the withUrl() method to pass a plain text URL with the query parameter:

$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->copy()->withUrl(
    $graphServiceClient->getRequestAdapter()->getBaseUrl()."/drives/{$driveId}/items/{$itemId}/copy"
)->post($requestBody)->wait();

Let me know if this works.

@Ndiritu Ndiritu added dependency:metadata Awaiting fix from core dependency project module and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jul 12, 2024
@JeroenTriptic
Copy link
Author

Sorry for the late response. The withUrl function does indeed function as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency:metadata Awaiting fix from core dependency project module type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants