Cosmos DB Rest API - unable to get document after passing partition key

Abdullah Humayun 40 Reputation points
2024-05-19T07:51:45.2233333+00:00

Trying to get a document by its id using the following API (https://learn.microsoft.com/en-us/rest/api/cosmos-db/get-a-document). However, after providing the value for x-ms-documentdb-partitionkey I keep getting a not found error message despite the document existing.

A sample document is attached below:

User's image

And the partition key is defined below:
User's image

Note that I can use the list documents API with no issues, it shows all the documents in the collection as expected.

I am using Postman to send the API request.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,476 questions
0 comments No comments
{count} votes

Accepted answer
  1. TP 79,331 Reputation points
    2024-05-19T08:06:19.2833333+00:00

    Hi,

    x-ms-documentdb-partitionkey needs to be set to the partition key value. For your sample document you would set it to "personal".

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful