![](/img/trans.png)
[英]Azure Service Bus Queue sending a message in NodeJs to .NET client
[英]Sending message to Azure Service Bus from POSTMAN nodeJs
我一直在嘗試從 POSTMAN 向 Azure 服務總線主題發送示例消息,但出現了異常錯誤。 我的疑問是,我正在使用 NodeJs 自己的“緩沖區”而不是“utf8”模塊生成 SAS 令牌。 這可能是我收到“指定的 HTTP 動詞 (POST) 無效”的原因。 . 這是我生成 SAS 令牌的代碼段。
*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;
}*
它是帶有 Authorization 和 Content-Type 標頭的 POST 調用。
請在網址末尾添加“消息”:
http{s}://{serviceNamespace}.servicebus.windows.net/{queuePath|topicPath}/messages
-> https://mynamespace.servicebus.windows.net/my-topic-name/messages
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.