

So the body is turned into base64 to prevent possible errors with other resources.īy convention, the IoT Hub and surrounding tooling assume it's just JSON, in Base64 encoding.

In this case, messages travel through Azure as 'Event data', see also this documentation. Training for Azure IoT is available for free. If you want to work with (Azure) IoT, you need to build up some basic knowledge about both the cloud and the way IoT is implemented in a particular vertical. But if not, who is encoding the data which is probably arriving unencoded ? Or is it doing decoding in the background silently ? I don't really think so. The most interesting part is that Azure Cloudshell event monitoring shows pure JSON data, no trace of base64. Azure IoT Hub CosmosDB event routing endpoint ?.So can someone point out which component is most probably doing the encoding ?
#BAD BASE64 ENCODING CODE#
I would like to start with a documentation / source code / blog, whatever that holds the promise to answer my original question : where is base64 encoding imposed ? There are thousands of pages to read in various topics and despite all are very interesting, I simply don't have the time to go through all or them. I am using ESP8266 C++ code and related libraries. Most of the examples presented is using C#, which is my absolute favorite language and environment, but unfortunately not relevant in this case. And, if you have any further query do let us know by commenting in the below section. If this answers your query, do click Accept Answer as helpful. Please let us know if you still need any further clarification on this. Hope this addresses the issue you are facing. If you route the data to blob container, you would see the message would still be in base64 format. Kindly note that, the message format you see when you monitor the built in event end point in Azure cloud shell is not accurate depiction of the data received by the IoT Hub. Here is the documentation on MQTT provided on IoT Hub that provides this explanation Please refer the below image for reference. Once you set the parameters, you can view the message in the correct format. Please note to replace the Topic with the appropriate device to which you would like to send the data. mqtt_client.beginMessage(telemetry_topic) Mqtt_client.publish(topic, strJSON, false) doc = "25" Ĭhar topic = "devices//messages/events/$.ct=application%2Fjson%3Bcharset%3Dutf-8" Since we are publishing the data using MQTT topic name, we can set these parameters at the end as follows. To overcome this, we need to specify the Content Type and Encoding Type before sending the message. Hi Frank The encoding is done as the message gets send to the IoT Hub, which is the PubSubClient step in this case.
