An Azure NoSQL database service for app development.
Cosmos DB SQL without postman
Hi Team,
I'm using CosmosDB to store the JSON documents. The database gives inbuilt SQL REST API feature to query the database.
With this inbuilt feature I'm able to query data perfectly using GET and POST methods. This is working perfectly alright using "Postman". Now I want to try this for real consumer, which is not working.
I've imported the cosmosdb queries from git (https://github.com/MicrosoftCSA/documentdb-postman-collection) which is recommended by Microsoft in one of its tutorials .
Now when I looked this in detail, I see that Postman is using "Pre-request Script" where it is modifying
var mastKey = postman.getEnvironmentVariable("DocumentDBMasterKey");
master key - var key = CryptoJS.enc.Base64.parse(mastKey);
var signature = CryptoJS.HmacSHA256(text, key);
var base64Bits = CryptoJS.enc.Base64.stringify(signature);
var MasterToken = "master";
var TokenVersion = "1.0";
auth = encodeURIComponent("type=" + MasterToken + "&ver=" + TokenVersion + "&sig=" + base64Bits)
With this pre-script it works perfectly alright. But as a consumer how would I consume this?
- Should consumer really bother about this script or he should just provide authentication token and required headers and the API should just work?
- If consumer really need to write this pre-script, where would he write?
Any help would be highly appreciated.
Thanks
Azure Cosmos DB
1 answer
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
5 deleted comments
Comments have been turned off. Learn more