Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ludmillab
Contributor II
Contributor II

ApplyPatches on root element

Is it possible to use applypatches with path "/"? 

I have tried this:

 

var patch = new NxPatch() { Op = NxPatchOperationType.Replace, Path = "/", Value = "{ \"title\": \"Min rubrik\" }" };
var patches = new NxPatch[] { patch };
await genericObject.ApplyPatchesAsync(patches, true);

but it complains that my JSON has a bad format (Invalid parameters [8]:Invalid parameters(Patch value not on valid JSON format.)). My intention is not to change only the title, it is a small test. I would like to apply a whole JSON object of properties, because I find it very tedious to search for paths and values in the properties.

 

I have already tried this, and it works:

 

var patch = new NxPatch() { Op = NxPatchOperationType.Replace, Path = "/title", Value = "\"Min rubrik\"" };

 

so please don't give me that advice.

 

 

1 Reply
Øystein_Kolsrud
Employee
Employee

No, patching the root element is not supported today. I guess typically if you want to patch the root you can simply set the full property set, but in your case I see you are using the soft patch argument. Is that why you want to patch the root?