首页 > 解决方案 > How to parse a message in Azure IOT hub logic app

问题描述

I am trying to understand how to get content into a logic app email (or into the conditioning search in the logic app).

I have an IOT device sending a standard message to the hub (the demo temperature app). This works fine.

I have added a service bus and routing and again all ok.

I then want a logic app to send an email either using some of the content of the message, or even to use the conditional processing in the logic app.

I am using the connector in the logic app to the service bus.

When I try emailing dependant on the conditional "Content contains Startup" the email goes successfully but only down the false route.

When I try to put a JSON parse step in is returns invalid as the content isn't in JSON format.

The Error message:

InvalidJSON. The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value 'e3sid2ZNZXNzYWdlVHlwZSI6IFN0YXJ0dXAsInRlbXBlcmF0dXJlIjogMzcuMzMsImh1bWlkaXR5IjogNjEuMjV9' cannot be parsed: 'Unexpected character encountered while parsing value: e. Path '', line 0, position 0.'.

标签: azureiotazure-logic-apps

解决方案


很难准确理解问题发生在哪里,但看起来你的字符串在 base64 中。

您可以尝试使用以下方法进行转换:

base64ToString(triggerBody()?['whateveryourvariablenameis'])

查看此屏幕截图和更多信息: Azure Logic App 服务总线消息内容


推荐阅读