JSON Format for Messages from TTN

Hello all!

I have two LoRaWAN sensors sending data to Azure IoT Hub through a Dragino hub. Everything is working fine, except the Body is always formatted in Base64, and I want it in JSON form.

I found this article on Microsoft Learn about how to format messages sent to IoT Hub, and I believe I need to add $.ct=application%2Fjson&$.ce=utf-8 to the end of the topic. How can I do that? https://learn.microsoft.com/en-us/azure/iot/iot-mqtt-connect-to-iot-hub#sending-device-to-cloud-messages


There seem to be some contradictory info in all of this so some questions to get clarity:

  1. Can you show us what you mean by “the Body is always formatted Base64” - some parts of the JSON are in Base64 format, particularly frm_payload which would be as expected.
  2. The link you gave is for MQTT and we don’t get to change the format of the MQTT message, are you also using the MQTT integration or is that just part of your Azure IoT Hub?

Hi Nick,

Certainly, I can give some detail. I had two different thoughts in my mind, the format of the body and the ability to add a string to the end of the MQTT topic for Azure IoT Hub, sorry about that.

  1. The message sent from TTN to Azure IoT Hub has this form:

    And as you can see, the Body property is a long Base64 string. Unreadable. I want that Body parameter to be a JSON string, so I can read it directly from the database.

Translated from Base64, the Body property is what is shown below. (I removed sensitive data and replaced with x’s, but this has everything we need for this post)
The frm_payload is sent as Base64 with encoding, I get that, but I want the “decoded_payload” to come through with no decoding needed, which means I want the decoded Body property as shown below to be sent.

	"end_device_ids": {
		"device_id": "eui-24e124743e043333",
		"application_ids": {
			"application_id": "lorawan-sensors"
		"dev_eui": "x",
		"join_eui": "x",
		"dev_addr": "x"
	"received_at": "2024-04-08T13:29:56.374311155Z",
	"uplink_message": {
		"session_key_id": "x",
		"f_port": 85,
		"f_cnt": 18,
		"frm_payload": "AXVkBVsBiAFYAmwD",
		"decoded_payload": {
			"channel2Value": 5,
			"channelValue": 1,
			"header2Name": 91,
			"header2Value": 1,
			"headerName": 117,
			"headerValue": 100,
			"value1": 392,
			"value2": 600,
			"value3": 876
  1. I am using the Things Network IoT Hub integration: https://www.thethingsindustries.com/docs/integrations/cloud-integrations/azure-iot-hub/ It uses MQTT to send messages to Azure. That’s mostly what this post was about, can I change the MQTT settings of what TTN is sending.
    It sounds like I can’t, so you might have answered my question.
    Can I make a future feature suggestion somewhere? We should be able to direct which MQTT topics our messages are sent to, that way we can specify the message type.

Thanks for your time!

FYI, EUIs and DevAddr are publicly exposed info. The only thing to redact is keys, device & API plus any decoded payloads that have racey information in it.

As the big cloud providers like to play musical chairs with the services they offer, like MS dropping Azure IoT Central, I’m not a regular user of such things.

Did you use the template when you deployed?

Or try creating a new deployment just in case there was a glitch in the setup.

From a prior conference: First look: The Things Network new Azure IoT Hub integration – Sander van de Velde

GitHub issues.

Should is a very strong word to use for a free service that costs someone else thousands a month to provide. But with a paid for instance + support I’m sure they’d look at it for you.