Azure事件中心上的POST数据失败

问题描述 投票:0回答:1

这与Azure事件中心有关,我正尝试使用POST API从POSTMAN发送数据到事件中心。

我遵循的步骤:

创建的事件中心,生成SAS发送令牌,已创建的消费者组

现在是邮递员,我正在努力格式化正确的标题:

我发送的请求:

POST:  https://testeventhu.servicebus.windows.net/myhub 

2个标题:

Content-Type : application/atom+xml;type=entry;charset=utf-8

Authorization:  SharedAccessSignature sig=kjheh/f6SqR8dIW2nRpGUCHuhdshss2KoCKo7Q6ozmY=&se=1571140739&skn=saspolicy&sr=https://testeventhu.servicebus.windows.net/myhub

并且我收到错误消息401 MalformedToken:无法解析简单的Web令牌

我在这里做什么错?所用的参考来自https://docs.microsoft.com/en-us/rest/api/eventhub/Send-event?redirectedfrom=MSDN

提前感谢

azure post azure-eventhub-capture
1个回答
0
投票

请按照以下步骤操作:

1。在azure门户中创建eventhub namesapceeventhub实例->在azure门户中,导航至eventhub namespace->共享访问策略,然后单击“添加”按钮以创建一个sas策略(在这里,我只是选择“发送”特权以进行发送)。屏幕截图如下:

enter image description here

2。生成sas令牌,我根据此link通过powershell创建了sas令牌。这是我的powershell代码和返回的sas令牌:

enter image description here

3。在邮递员中:

请求URL应该是这样,记住在末尾添加messageshttps://your_eventhub_namespace.servicebus.windows.net/your_eventhub_instance/messages

标题:

授权:步骤2中的sas令牌

内容类型:application / atom + xml; type = entry; charset = utf-8

主机(可选):your-eventhub-namespace.servicebus.windows.net

下面的屏幕截图,您可以看到返回的状态码是201创建的:

enter image description here

并且如果您不知道如何设置邮件正文,则可以在邮递员的正文中看到我的邮件:

enter image description here

如果仍有任何问题,请随时告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.