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

@microsoft.graph.conflictBehavior in driveitem copy #981

Closed
1 of 3 tasks
indigane opened this issue Jan 15, 2019 · 11 comments
Closed
1 of 3 tasks

@microsoft.graph.conflictBehavior in driveitem copy #981

indigane opened this issue Jan 15, 2019 · 11 comments

Comments

@indigane
Copy link

indigane commented Jan 15, 2019

Category

  • Question
  • Documentation issue
  • Bug

Expected or Desired Behavior

Copying a driveitem allows for defining @microsoft.graph.conflictBehavior to handle conflicts, as per design according to issue #759

This should also be documented.

Observed Behavior

Conflicts cause 409 Conflict response despite @microsoft.graph.conflictBehavior.

{
  "error": {
    "code": "nameAlreadyExists",
    "message": "The specified item name already exists.",
    "innerError": {
      "request-id": "{requestId}",
      "date": "{date}"
    }
  }
}

Steps to Reproduce

POST https://graph.microsoft.com/v1.0/users/{username}/drive/items/{itemId}/copy

{
  "parentReference": {
    "driveId": "{driveId}",
    "id": "{parentItemId}"
  },
  "name": "foo",
  "@microsoft.graph.conflictBehavior": "rename"
}

^ Making this request twice will cause 409 Conflict nameAlreadyExists on the second try.

@indigane indigane changed the title @microsoft.graph.conflictBehavior in file copy @microsoft.graph.conflictBehavior in driveitem copy Jan 15, 2019
@ificator ificator self-assigned this Jan 15, 2019
@Herz3h
Copy link

Herz3h commented Aug 8, 2019

I'm trying this aswell using the Graph API and it always returns nameAlreadyExists regardless of the behaviorConflict specified

{
  "parentReference": {
    "driveId": "{driveId}",
    "id": "{parentItemId}"
  },
  "name": "test",
  "@microsoft.graph.conflictBehavior": "rename"
}

How to work around this ??

@8ggmaker
Copy link

8ggmaker commented Sep 1, 2019

any updates?

@kostenickj
Copy link

come on guys?

@greenygh0st
Copy link

I can also confirm that this still does not function properly.

@marcogiannetta
Copy link

Adding @microsoft.graph.conflictBehavior=rename to query string parameters did work for me

@jl0zano
Copy link

jl0zano commented Dec 8, 2020

as @marcogiannetta said, you have to add to the query params.

Example:
https://graph.microsoft.com/v1.0/me/drive/items/{your-file-id}/copy?@microsoft.graph.conflictBehavior=rename

If you're using the C# Graph SDK you have to send a query option on the request.

List<QueryOption> options = new List<QueryOption>
{
    new QueryOption("@microsoft.graph.conflictBehavior", "rename")
};

Source: https://stackoverflow.com/a/44991860/14457092

@Herz3h
Copy link

Herz3h commented Dec 8, 2020

Well docs should be updated then

@Cnly
Copy link

Cnly commented Jan 5, 2021

It looks like the workaround above only works for OneDrive for Business... OneDrive Personal still seems to ignore it.

@Herz3h
Copy link

Herz3h commented Mar 19, 2021

Adding @microsoft.graph.conflictBehavior to query string doesn't work either:

https://graph.microsoft.com/v1.0/me/drive/items/{your-file-id}/copy?@microsoft.graph.conflictBehavior=replace

Edit: It actually works, my bad. I just had different unrelated error (overwrite is not supported for folders)

@czernas
Copy link

czernas commented Mar 25, 2021

Does not work with the personal accounts. 😒

@patrick-rodgers
Copy link
Contributor

As part of a repository clean up effort we are closing older issues. If this issue remains, please: open a new issue, reference this issue, and provide any additional details that may help in resolution. Thank you for your understanding as we work to improve our responsiveness.

@OneDrive OneDrive locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

13 participants