Replacing a document with an updated json property

Hi All

I am trying to replace an existing documnet with an updated one and it is throwing an error ‘the output byte buffer is too small to contain the encoded data’

var bucket = await cluster.BucketAsync("");
var scope = await bucket.ScopeAsync("scopename");
var collection = await scope.CollectionAsync("collectionname");
var getResult = await collection.GetAsync("documentname");
var existingDoc = getResult.ContentAs<JObject>();
Console.WriteLine(existingDoc);

var currentCas = getResult.Cas;
Console.WriteLine($"Current Cas: {currentCas}");
                       

var replaceResult = await collection.ReplaceAsync(updatedJson, existingDoc, options => { options.Cas(currentCas); });

Please help and let me know if there anything wrong in here .
Thanks