我已经使用event schema =“ Event Grid Schema”在天蓝色创建了事件网格主题。
对我来说,下一步是尝试将消息发送到该事件网格主题,以便订阅者可以在事件网格主题中成功接收到消息后执行某些操作。
但是,将消息发送到事件网格主题时遇到了问题。它始终会拒绝我的JSON请求,并显示错误消息“未设置必填属性'subject'。甚至更难,我已经在JSON帖子正文中明确设置了主题。
我还在标头中添加了“ 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中提供主题吗?
答案 0 :(得分:0)
基于文档:
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
}
]
答案 1 :(得分:0)
如果使用Azure门户创建了主题,那么是否在某处指定了inputSchemaMapping?
根据此处的规范:https://docs.microsoft.com/en-us/rest/api/eventgrid/topics/createorupdate
选择CustomEventSchema时需要指定inputSchemaMapping。