Cloud Stack Ninja

I have been trying to send a sample message to Azure Service Bus Topic from POSTMAN, But it came with an unusual error. Here my doubt is, I am generating the SAS token using NodeJs own 'Buffer' rather than 'utf8' module. Can that be a reason Why I am getting 'The specified HTTP verb (POST) is not valid.'. Here is my snippet to generate the SAS token.

*function createSharedAccessToken(uri, saName, saKey) {
    if (!uri || !saName || !saKey) {
        throw "Missing required parameter";
    console.log('inside the function')
    var encoded = encodeURIComponent(uri);
    var now = new Date();
    var week = 60 * 60 * 24 * 7;
    var ttl = Math.round(now.getTime() / 1000) + week;
    var signature = encoded + '\n' + ttl;
    var signatureUTF8 = Buffer.from(signature, 'utf8');
    var hash = crypto.createHmac('sha256', saKey).update(signatureUTF8).digest('base64');
    return 'SharedAccessSignature sr=' + encoded + '&sig=' +
        encodeURIComponent(hash) + '&se=' + ttl + '&skn=' + saName;

Its a POST call with Authorization and Content-Type header.

Read more here:

Content Attribution

This content was originally published by Satya Panigrahy at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: