Onedrive-api-docs: `@microsoft.graph.conflictBehavior` in driveitem copy

Created on 15 Jan 2019  路  9Comments  路  Source: OneDrive/onedrive-api-docs

Category

  • [ ] Question
  • [ ] Documentation issue
  • [x] 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.

Docs bug

Most helpful comment

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

All 9 comments

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 ??

any updates?

come on guys?

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

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

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

Example:
https://graph.microsoft.com/v1.0/me/drive/items/{your-file-id}/[email protected]=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

Well docs should be updated then

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

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

https://graph.microsoft.com/v1.0/me/drive/items/{your-file-id}/[email protected]=replace

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcreicher picture marcreicher  路  3Comments

kverhoef picture kverhoef  路  3Comments

brownbl1 picture brownbl1  路  10Comments

atkinchris picture atkinchris  路  6Comments

neunygph picture neunygph  路  9Comments