ContentEncoding format

Praveen Kumar 1 Reputation point
2021-07-29T09:35:47.583+00:00

Hi All,

Can somebody help me here quickly?

I am receiving one json from device which contain some special character so while sending to iot hub, I have set the ContentEncoding = "utf-8" below is the code .
Message iotHubMessage = new Message(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(messageObject)))
{
ContentEncoding = "utf-8",
ContentType = "application/json"
};
Json I am receiving from device

{
"nameKey": "StO2",
"name": "StO₂ A2",
"englishName": "StO₂ A2",
"parameterType": "StO2A2",
"isUnassignedValue": false,
"measurementUnitsValue": 62.785713195800781,
"measurementUnitsValueWithPrecision": 63.0,
"formattedValue": "63",
"formattedEnglishLowerAlarmMessage": "Alarm: StO₂ A2 is below low limit",
"formattedEnglishUpperAlarmMessage": "Alarm: StO₂ A2 exceeded high limit",
}

So when I am checking the data IoT hub side some addition character is getting added looks like it in unable to encode O2.
Json from IoT hub:

{
"nameKey": "StO2",
"name": "StO??? A1",
"englishName": "StO??? A1",
"parameterType": "StO2A1",
"isUnassignedValue": false,
"measurementUnitsValue": 61.28571319580078,
"measurementUnitsValueWithPrecision": 61.0,
"formattedValue": "61",
"formattedEnglishLowerAlarmMessage": "Alarm: StO??? A1 is below low limit",
"formattedEnglishUpperAlarmMessage": "Alarm: StO??? A1 exceeded high limit",
}

see the "englishName" in both the json.

Can somebody help me here how can i get the same json?.
What can I do in code level ?.

Please help me here.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
{count} votes

1 answer

Sort by: Most helpful
  1. QuantumCache 20,676 Reputation points Moderator
    2021-08-09T04:24:25.273+00:00

    Hello @Praveen Kumar Just checking in on the reported issue. Could you please confirm if your IOT-Hub is receiving the right encoded message from the device?

    I have just quickly tested the stage of message sending with special characters like StO₂ A2

    I have used the web-Simulator to quickly send and read the telemetry as shown in the below image.

    https://azure-samples.github.io/raspberry-pi-web-simulator/

    121464-image.png

    Please comment in the below section for help in this matter, we would be happy to help you.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.