2
votes

I am hitting my stored procedure API in azure Cosmos DB, but I am getting back the message

{
"code": "BadRequest",
"message": "Message: {\"Errors\":[\"PartitionKey extracted from document doesn't match the one specified in the header\"]}\r\nActivityId: afd48989-60b5-489d-95ce-e999fc5561c9, Request URI: /apps/497cb807-5f70-43d9-a68c-a742815f6016/services/fae8a265-85a1-4d9b-904e-7a996901d928/partitions/ecdbf51b-d1f2-46d4-8b42-9ddbbf39aa1a/replicas/131818407837945845p, RequestStats: \r\nRequestStartTime: 2018-10-15T18:08:20.5929270Z, Number of regions attempted: 1\r\n, SDK: Microsoft.Azure.Documents.Common/2.1.0.0"
}

I know that I need to provide the partition key, but I am unsure how to. Is it in the body? Provided as a header? I've tried both of these in Postman with no luck. Using Postman, how would you format your request to send the partition key to the stored procedure?

Examples I've tried (on a POST request)

  1. Tried adding a header called "PartitionKey" with a value of 51.

  2. Tried sending an array with the partition key ["51"] in the body raw since the body is supposed to contain a parameters array.

  3. Tried the following raw json body

    {
        "PartitionKey": "51"
    } 
    
1
Hi,does my answer helps you?Jay Gong

1 Answers

2
votes

Based on the cosmos db Common REST request headers, you need to specify the partition key with x-ms-documentdb-partitionkey parameter.

{x-ms-documentdb-partitionkey : '51',...}