dev
dev

Reputation: 195

how to insert json into cosmos db collection using c#

I have a Json file which I wanted to store in a cosmos DB Collection. How can I add a complete Json file using C#? Is there any client library for the same?

but getting below issue with it

Response status code does not indicate success: 400 Substatus: 1001 Reason: (Message: {"Errors":["PartitionKey extracted from document doesn't match the one specified in the header"]}

How do I resolve it?


I have reference this tutorial:

Quickstart - .NET client library - Azure Cosmos DB for NoSQL | Microsoft Learn

Upvotes: 3

Views: 2280

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222522

Seems like you are passing wrong partition key value.

Make sure to specify the partition key value and not the attribute i.e. you would write x-ms-documentdb-partitionkey: [ "value" ].

Upvotes: 3

Related Questions