Forum Discussion

Paul_Red1's avatar
Paul_Red1
Copper Contributor
Dec 16, 2020

Cannot get conflict behaviour to work with upload to sharePoint

Hi. I am trying to get the various settings of fail/replace/rename to work, in both C# code and when this has failed in Postman. I am using it in an upload session. The URL is https://graph.microsoft.com/v1.0/sites/mysite/drives/driveidhere/root:/testfile.txt:/createUploadSession

 

The JSON body is 

{
  "@microsoft.graph.conflictBehavior""rename"
}
 
This generates a session URL and within my C# code then goes on to upload perfectly. But it always does a replace. Looking at the upload URL is shows the conflict behaviour which is always:
nameConflictBehavior=Replace
So Pernille-Eskebo.graph.conflictBehavior is not being recognised. I've tried rename and fail.
Any ideas?
 
Thanks
 
Paul
 
 
  • davidbabayan's avatar
    davidbabayan
    Copper Contributor

    Paul_Red1 as states the documentation at driveItem resource type:

     

    Notes: The parameter @microsoft.graph.conflictBehavior should be included in the URL instead of the body of the request.

     

    So try to include it in the URL not in the body.

    • rvpanchal's avatar
      rvpanchal
      Copper Contributor
      Hi All, I am also facing the same issue in my code. While creating uploadsession, unable to get proper session created.

      Even though the properties set to

      "@microsoft.graph.conflictBehavior": "fail",

      Its overwriting the files.

      Could any one please help. I am using golang and Code is
      http.newRequest(POST, URL, Body)
      Body = {
      "@microsoft.graph.conflictBehavior": conflictOption,
      "description": "",
      "name": filePath,
      "item": map[string]string{"@microsoft.graph.conflictBehavior": conflictOption},
      "deferCommit": true}

      Also I have tried all possible combinations for setting up properties. graph api always sending response which is overwriting the file in onedrive.

Resources