I'm trying to get documents from CosmosDB (SQL) through the REST API. With an Azure Function I determine the authorization string according to the code in the documentation.
I call this code with the following parameters:
GenerateAuthToken("GET", "docs", "dbs/vacancies/colls/items/docs", "masterkey", "master", "1.0");
I just want to get the documents in the database vacancies and in the collection items. These entities exist in CosmosDB (case sensitive match), and there is a document in that collection.
Then I use postman to call the Cosmos REST API. I do a HTTP GET to https://mycosmosdbaccount.documents.azure.com/dbs/vacancies/colls/items/docs headers:
x-ms-version : 2017-02-22
Accept: application/json
Authorization: type%3dmaster%26ver%3d1.0%26sig%3dDU1O3I0hMJzF76fedro4M2VnfOhE03aIWgccaVWRBIc%3d
x-ms-date: thu, 18 jan 2018 10:53:23 gmt
I get back:
{
"code": "Unauthorized",
"message": "The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'get\ndocs\ndbs/vacancies/colls/items\nthu, 18 jan 2018 14:31:43 gmt\n\n'\r\nActivityId: 637276f1-c4ec-4d5d-8199-022d680b31d2, Microsoft.Azure.Documents.Common/1.19.162.2"
}
I've tried about a hundred different combinations of the resourceLink (dbs/vacancies/colls/items/docs) and the http get URL with always the same result.
Please let me know what dumb thing I'm doing wrong.