Cannot get conflict behaviour to work with upload to sharePoint

%3CLINGO-SUB%20id%3D%22lingo-sub-1995331%22%20slang%3D%22en-US%22%3ECannot%20get%20conflict%20behaviour%20to%20work%20with%20upload%20to%20sharePoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1995331%22%20slang%3D%22en-US%22%3E%3CP%3EHi.%20I%20am%20trying%20to%20get%20the%20various%20settings%20of%20fail%2Freplace%2Frename%20to%20work%2C%20in%20both%20C%23%20code%20and%20when%20this%20has%20failed%20in%20Postman.%20I%20am%20using%20it%20in%20an%20upload%20session.%20The%20URL%20is%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fsites%2Fmysite%2Fdrives%2Fdriveidhere%2Froot%3A%2Ftestfile.txt%3A%2FcreateUploadSession%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fsites%2F%3CEM%3Emysite%3C%2FEM%3E%2Fdrives%2F%3CEM%3Edriveidhere%3C%2FEM%3E%2Froot%3A%2Ftestfile.txt%3A%2FcreateUploadSession%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20JSON%20body%20is%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%40microsoft.graph.conflictBehavior%22%3C%2FSPAN%3E%3CSPAN%3E%3A%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22rename%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EThis%20generates%20a%20session%20URL%20and%20within%20my%20C%23%20code%20then%20goes%20on%20to%20upload%20perfectly.%20But%20it%20always%20does%20a%20replace.%20Looking%20at%20the%20upload%20URL%20is%20shows%20the%20conflict%20behaviour%20which%20is%20always%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EnameConflictBehavior%3DReplace%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ESo%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F41501%22%20target%3D%22_blank%22%3E%40microsoft%3C%2FA%3E.graph.conflictBehavior%20is%20not%20being%20recognised.%20I've%20tried%20rename%20and%20fail.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EAny%20ideas%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EThanks%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EPaul%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1996638%22%20slang%3D%22en-US%22%3ERe%3A%20Cannot%20get%20conflict%20behaviour%20to%20work%20with%20upload%20to%20sharePoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1996638%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F904363%22%20target%3D%22_blank%22%3E%40Paul_Red1%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20to%20say%20I%20have%20this%20working%20-%20the%20documentation%20is%20appalling!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20page%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fdriveitem-createuploadsession%3Fview%3Dgraph-rest-1.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fdriveitem-createuploadsession%3Fview%3Dgraph-rest-1.0%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Edoes%20not%20show%20that%20in%20the%20%3CSTRONG%3Erequest%3C%2FSTRONG%3E%20the%20conflict%20behaviour%20setting%20should%20be%20wrapped%20in%20an%20%22item%22%20object.%20Please%20can%20we%20have%20some%20more%20examples%20in%20the%20documentation.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

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:/createUploadSes...

 

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 @microsoft.graph.conflictBehavior is not being recognised. I've tried rename and fail.
Any ideas?
 
Thanks
 
Paul
 
 
2 Replies

@Paul_Red1 

Just to say I have this working - the documentation is appalling!

 

The page https://docs.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0

 

does not show that in the request the conflict behaviour setting should be wrapped in an "item" object. Please can we have some more examples in the documentation.

 

Thanks

 

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.