我使用触发器“当接收到HTTP请求时”,然后使用“发布事件”操作将多个事件发布到事件网格。For循环可以很好地拆分获得并创建要发布的事件的JSON,但是发布仍然会失败。
{
"error": {
"code": "UnsupportedMediaType",
"message": "The Content-Type header is either missing or it doesn't have a valid value. The content type header must either be application/cloudevents+json; charset=utf-8 or application/cloudevents-batch+json; charset=UTF-8. Report 'edf36bbd-9221-4882-8a29-2264ffb16d72:3:3/6/2020 2:18:20 PM (UTC)' to our forums for assistance or raise a support ticket.",
"details": [
{
"code": "InvalidContentType",
"message": "The Content-Type header is either missing or it doesn't have a valid value. The content type header must either be application/cloudevents+json; charset=utf-8 or application/cloudevents-batch+json; charset=UTF-8. Report 'edf36bbd-9221-4882-8a29-2264ffb16d72:3:3/6/2020 2:18:20 PM (UTC)' to our forums for assistance or raise a support ticket."
}
]
}
}我假设发布时使用了输入的头部,所以我尝试在发布时更改Publish_Event块中的标头,如下所示(直接在代码视图中,因为它在UI中不受支持),因此我得到了以下内容(添加了header部分):
"Publish_Event": {
"inputs": {
"body": [
{
"data": "@items('For_each_2')",
"eventType": "company-location",
"id": "ID : @{items('For_each')['businessId']}",
"subject": "Company Location changed"
}
],
"headers": {
"Content-Type": "application/cloudevents+json; charset=utf-8"
},
"host": {
"connection": {
"name": "@parameters('$connections')['azureeventgridpublish']['connectionId']"
}
},
"method": "post",
"path": "/eventGrid/api/events"
},
"runAfter": {},
"type": "ApiConnection"
}但这也不起作用。没有找到行动来做改变。
我的全部流程如下:

作为测试数据,我使用以下JSON与postman一起发送(稍微简化了一点):
[
{
"id": 3603,
"businessId": "QQTADOSH",
"locations": [
{
"id": 5316,
"businessId": "A-yelr3g"
},
{
"id": 5127,
"businessId": "A-c7i8gd"
},
{
"id": 5403,
"businessId": "A-fjdd2y"
},
{
"id": 6064,
"businessId": "A-rqvhz8"
}
]
},
{
"id": 3118,
"businessId": "Cr11_Macan_111qa",
"locations": [
{
"id": 4563,
"businessId": "A-3bv860"
}
]
}
]发布于 2020-03-09 10:36:00
看来正式事件网格发布连接器不支持云事件模式。
您可以将主题设置为接受事件网格模式,但我相信这只有在创建时才有可能。
最好打开一个UserVoice上的特征请求来添加对此的支持,同时,解决方法是使用HTTP行动到张贴到自定义主题。
但是确实注意到,解决方法需要构建要发送的事件有效负载(以及获取访问键从钥匙库而不是直接存储在工作流中)。
https://stackoverflow.com/questions/60566882
复制相似问题