Hi anonymous user,
Thanks for using Microsoft Q&A !!
If my understanding is correct, you are getting error while trying to update a document using container.PatchItemAsync
method using CosmosDB .NET SDK.
I have tried this in my environment and it worked fine using your code.
List<PatchOperation> patchOperations = new List<PatchOperation>();
patchOperations.Add(PatchOperation.Set("/Property1", "Patched"));
try
{
ItemResponse<dynamic> item = await container.PatchItemAsync<dynamic>(
"order1",
new PartitionKey("partitionKey1"),
patchOperations
);
}
catch (Exception e)
{
Console.WriteLine(e);
}
Before Patch:
Result:
I believe you are passing the attribute which is being used as a partition key instead of passing PartitionKey for the item. However, can you please make sure that you are passing the correct Partition Key for the item.
You could further look into this document to troubleshoot any other potential causes of this error.
Please let me know if you have any questions.
Thanks
Saurabh