我使用事件架构 =“事件网格架构”在 azure 中创建了事件网格主题。
我的下一步是尝试将消息发送到该事件网格主题,以便订阅者可以在事件网格主题中成功接收消息时执行某些操作。
但是,我在将消息发送到事件网格主题时遇到了问题。它总是拒绝我的 JSON 请求,并显示错误“未设置必需的属性‘主题’。即使很困难,我也已在 JSON 帖子正文中显式设置了主题。
我还在 header 中添加了“aeg-sas-key”值以进行身份验证。
这是我的 JSON 格式的示例:
{
"id": "19291",
"subject": "myapp/vehicles/motorcycles",
"topic": "VehicleData",
"eventType": "statusupdated",
"eventTime": "2019-05-12T18:41:00.9584103Z",
"data":{
"firstName": "Jason",
"postalAddress": "xyz"
},
"dataVersion": "1.0",
"metadataVersion": "string"
}
这是输出:
{
"error": {
"code": "BadRequest",
"message": "Required property 'subject' was not set. Report '433759ee-6570-466e-ae12-a6dc5fccbfe1:5/14/2019 4:01:32 AM (UTC)' to our forums for assistance or raise a support ticket.",
"details": [
{
"code": "InputJsonInvalid",
"message": "Required property 'subject' was not set. Report '433759ee-6570-466e-ae12-a6dc5fccbfe1:5/14/2019 4:01:32 AM (UTC)' to our forums for assistance or raise a support ticket."
}
]
}
}
知道为什么它总是要求主题,即使我已经在 JSON 中提供了主题?
最佳答案
基于文档:
Post to custom topic for Azure Event Grid
使用以下有效负载:
[
{
"id": "19291",
"subject": "myapp/vehicles/motorcycles",
"topic": null,
"eventType": "statusupdated",
"eventTime": "2019-05-12T18:41:00.9584103Z",
"data": {
"firstName": "Jason",
"postalAddress": "xyz"
},
"dataVersion": "1.0",
"metadataVersion": null
}
]
关于json - 我们如何向事件网格主题发布消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56122842/