首页 > 解决方案 > 通过 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."  
    }  
}  

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

标签: azureazure-eventhub

解决方案


因为您错过了请求中的令牌Bearer,请尝试GET使用.BearerAuthorization

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

另外,我Bearer是通过powershell和fiddler获取token的,大家可以参考一下步骤。

1.运行下面的powershell。

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

2.使用fiddler捕获请求,它会发送两个请求,选择任何一个,复制token即可。

在此处输入图像描述

在邮递员中,GET使用Bearer令牌发送,它在我这边工作正常。

在此处输入图像描述


推荐阅读