I am following the Azure REST documentation for GET ACL Table, Authentication for the Azure Storage Services.
Below is the code snippet for REST operation I am performing.
//Input your Storage Account and access-key associated to it.
const yourStorageAccountName = '';
const accessKeyStorageAccount = '';
const Client = require('node-rest-client').Client;
const crypto = require("crypto");
async function getTableAcl() {
let now = new Date();
let nowUTC = now.toUTCString();
let contentType = "application/json"
// construct input value
let stringToSign = `GET\n\n\n${nowUTC}\n/${yourStorageAccountName}/tablename\ncomp:acl`;
let accesskey = accessKeyStorageAccount;
// create base64 encoded signature
let key = new Buffer(accesskey, "base64");
let hmac = crypto.createHmac("sha256", key);
hmac.update(stringToSign);
let sig = hmac.digest("base64");
console.log("SIGNATURE : " + sig);
console.log("nowutc : " + nowUTC);
let args = {
headers: {
"Authorization": "SharedKey " + yourStorageAccountName + ":" + sig,
"Date": nowUTC,
"x-ms-version": "2015-12-11"
}
};
let restClient = new Client();
restClient.get(`https://${yourStorageAccountName}.table.core.windows.net/tablename?comp=acl`, args, function (data, response) {
console.log(JSON.stringify(data));
//console.log(response);
});
}
getTableAcl()
The catch here is that there is no mention of Content-Type in Azure Table ACL documentation but in Authorization header part it is given to include Content-Type. Hence I am keeping the content-type as empty in "stringToSign" and am not providing the Content-Type header in the REST call. I might be missing something but I am not able to determine what it could be.
Can you let me know if I am mising anything in this case?