通过 POSTMAN 访问时无法获取事件中心描述

Failed to get Event Hub description when hitting via POSTMAN

我已经在 Azure 中创建了一个事件中心。

我正在尝试按照文档 https://docs.microsoft.com/en-us/rest/api/eventhub/eventhubs/get.

获取指定事件中心的事件中心描述

当我通过 POSTMAN 按以下 URL 替换文档中指定的值时:

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}?api-version=2017 -04-01

但我收到以下错误:-

    {  
    "error": {  
        "code": "AuthenticationFailed",  
        "message": "Authentication failed. The 'Authorization' header is missing."  
    }  
}  

知道如何获取有关事件中心的描述吗?

因为您错过了请求中的 Bearer 令牌,请尝试 GET 下面的 URL 和 Authorization 中的 Bearer 令牌。

https://management.azure.com/subscriptions/<subscriptionId>/resourceGroups/<resourcegroup>/providers/Microsoft.EventHub/namespaces/<yourEventhubName>?api-version=2015-08-01 

此外,我通过powershell和fiddler获得了我的Bearer令牌,你可以参考步骤。

1.Run下面的powershell。

Get-AzureRmResource -ResourceGroupName <ResourceGroupName >-ResourceType Microsoft.EventHub/namespaces -ResourceName "<yourEventHubName>" -ApiVersion 2015-08-01

2.Usefiddler抓到请求,会发送两个请求,任选一个,复制token即可。

在 Postman 中,使用 Bearer 令牌发送 GET,在我这边工作正常。