Lab-08 PartitionKey error
Closed this issue · 5 comments
Unhandled Exception: Microsoft.Azure.Cosmos.CosmosException: Response status code does not indicate success: 400 Substatus: 1001 Reason: (Microsoft.Azure.Documents.BadRequestException: Message: {"Errors":["PartitionKey extracted from document doesn't match the one specified in the header"]}
No matter what approach I take, no matter how much I research, I still am getting this error. I updated to the latest nuget package for CosmosDB, still getting this error.
I cannot continue the lab without this step.
Ok, so the fix is when you are creating a container in the portal, make sure the partition key is set to /Item.
You will need to create the database and the container manually.
Hi Daniel,
Unfortunately that didnt work for me. Do you have any other solution.
If I dont pass the partionkey to the CreateItemAsync method. It works. But I wanted to make work with passing Partitionkey
Matt
One more thing, I get only the exception reason code as "Response status code does not indicate success: 400 Substatus: 1001 Reason: ()."
Hey Mathews,
Is your reason blank in the error code?
You might need to do /YourPartitionKeyNameHere.
If that doesn't work, do you have a snippet of code?
Thanks Daniel for reaching out. I figured out the weird scenario. my partition key was defined as /PostCode which throws error while the Partition key /Postcode works. Not sure why MS is so particular abt case.
Note : On container it was defined as /Postcode