2

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?

I have already gone through the below URL Microsoft URL

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"]}ActivityId: 1ce4974b-0897-4823-9c04-be3acf358d9b, Request URI: /apps/52181d0a-9f43-4346-861f-c74d77b2f8c4/services/9b95b2b5-d989-4cf5-a0f7-afc6b4e4292d/partitions/ef42b5fd-48d6-4536-952e-9309285d38b1/replicas/132090639069807943p/, RequestStats: RequestStartTime: 2019-08-27T15:22:47.4097810Z, RequestEndTime: 2019-08-27T15:22:47.4498208Z, Number of regions attempted: 1ResponseTime: 2019-08-27T15:22:47.4498208Z, StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-eastus2-fd22.documents.azure.com:14122/apps/52181d0a-9f43-4346-861f-c74d77b2f8c4/services/9b95b2b5-d989-4cf5-a0f7-afc6b4e4292d/partitions/ef42b5fd-48d6-4536-952e-9309285d38b1/replicas/132090639069807943p/, LSN: 10, GlobalCommittedLsn: 10, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 1001, RequestCharge: 1.24, ItemLSN: -1, SessionToken: -1#10, UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Create, SDK: Windows/10.0.17134 cosmos-netstandard-sdk/3.1.4).

KJSR
  • 1,679
  • 6
  • 28
  • 51
dev
  • 163
  • 1
  • 11
  • I am literally watching a youtube video right now that answers this very question. I am just starting to learn CosmosDB. There are many, many, many videos on youtube that cover this. But at the very least, you need to show us your code. – Casey Crookston Aug 27 '19 at 15:44
  • Please refer to my Q&A, might help https://stackoverflow.com/questions/58121736/partitionkey-extracted-from-document-doesnt-match-the-one-specified-in-the-head – Gabriel P. Sep 27 '19 at 13:43

1 Answers1

3

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" ].

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396