Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

How to retrieve DocumentDB partitionkeys

For performance reasons I like to select documents from the DocumentDB belonging to a single partionkey - thus a list of partionkeys is essential. I have noticed that there is a REST API available, using a URL like

https://<database>.documents.azure.com:443/dbs/<databaseid>/colls/<collectionid>/pkranges (see https://docs.microsoft.com/nl-nl/rest/api/cosmos-db/get-partition-key-ranges)

Said that I tried this, getting through the hurdle of setting the appropriate authorization header which I think I have figured out. It is something like  type=master&er=1.1&sig=<read-only primary key>.

This all results in the following query (Advanced Editor)

 

let
    Source = Json.Document(Web.Contents("https://<database>.documents.azure.com:443/dbs/<databaseid>/colls/<collectionid>/pkranges",
[Headers=[authorization="type=master&ver=1.0&sig=<read-only primary key>"]]))
in
    Source

 

 

Unfortunately all I get is a returncode 400 (Bad Request) with the explaination "Web.Contents failed to get contents ... ". 

Is the above a road to succes? Or do I miss something?

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Using the RESTED Firefox extension I figured out that I missed two required headers ... x-ms-version and x-ms-date. Now I fail with the authorization token getting a 401 as response. More for research ...