HIVE MQ base64 encode

I’m currently utilizing HiveMQ Edge and have integrated an HTTPS adapter to make API calls and retrieve data. However, I’ve noticed that the data returned from these calls is encoded in base64.

For instance, the data I’m receiving looks like this: {"timestamp":1709178693978,"value":"data:application/json; charset=utf-8;base64,eyJjb29yZCI6eyJsb24iOi0wLjEyNTcsImxhdCI6NTEuNTA4NX0sIndlYXRoZXIiOlt7ImlkIjo4MDMsIm1haW4iOiJDbG91ZHMiLCJkZXNjcmlwdGlvbiI6ImJyb2tlbiBjbG91ZHMiLCJpY29uIjoiMDRuIn1dLCJiYXNlIjoic3RhdGlvbnMiLCJtYWluIjp7InRlbXAiOjI4My44OSwiZmVlbHNfbGlrZSI6MjgzLjM0LCJ0ZW1wX21pbiI6MjgyLjYyLCJ0ZW1wX21heCI6Mjg0LjksInByZXNzdXJlIjoxMDA2LCJodW1pZGl0eSI6ODl9LCJ2aXNpYmlsaXR5IjoxMDAwMCwid2luZCI6eyJzcGVlZCI6NC42MywiZGVnIjoyMTB9LCJjbG91ZHMiOnsiYWxsIjo3NX0sImR0IjoxNzA5MTc4MzAwLCJzeXMiOnsidHlwZSI6MiwiaWQiOjIwNzU1MzUsImNvdW50cnkiOiJHQiIsInN1bnJpc2UiOjE3MDkxODkyNDIsInN1bnNldCI6MTcwOTIyODMzNn0sInRpbWV6b25lIjowLCJpZCI6MjY0Mzc0MywibmFtZSI6IkxvbmRvbiIsImNvZCI6MjAwfQ=="}

can some one explain his

Hi @Nandhu

Warm greetings! It’s truly a pleasure to welcome you to the HiveMQ Community. We’re delighted to have you on board, exploring MQTT and the functionalities of the HiveMQ broker.

Regarding your inquiry about decoding the base64 string, if you’re using Linux, you can effortlessly achieve this by utilizing the base64 --decode command. Allow me to provide an example tailored to your specific base64 string:

# echo 'eyJjb29yZCI6eyJsb24iOi0wLjEyNTcsImxhdCI6NTEuNTA4NX0sIndlYXRoZXIiOlt7ImlkIjo4MDMsIm1haW4iOiJDbG91ZHMiLCJkZXNjcmlwdGlvbiI6ImJyb2tlbiBjbG91ZHMiLCJpY29uIjoiMDRuIn1dLCJiYXNlIjoic3RhdGlvbnMiLCJtYWluIjp7InRlbXAiOjI4My44OSwiZmVlbHNfbGlrZSI6MjgzLjM0LCJ0ZW1wX21pbiI6MjgyLjYyLCJ0ZW1wX21heCI6Mjg0LjksInByZXNzdXJlIjoxMDA2LCJodW1pZGl0eSI6ODl9LCJ2aXNpYmlsaXR5IjoxMDAwMCwid2luZCI6eyJzcGVlZCI6NC42MywiZGVnIjoyMTB9LCJjbG91ZHMiOnsiYWxsIjo3NX0sImR0IjoxNzA5MTc4MzAwLCJzeXMiOnsidHlwZSI6MiwiaWQiOjIwNzU1MzUsImNvdW50cnkiOiJHQiIsInN1bnJpc2UiOjE3MDkxODkyNDIsInN1bnNldCI6MTcwOTIyODMzNn0sInRpbWV6b25lIjowLCJpZCI6MjY0Mzc0MywibmFtZSI6IkxvbmRvbiIsImNvZCI6MjAwfQ==' | base64 -d | jq
{
  "coord": {
    "lon": -0.1257,
    "lat": 51.5085
  },
  "weather": [
    {
      "id": 803,
      "main": "Clouds",
      "description": "broken clouds",
      "icon": "04n"
    }
  ],
  "base": "stations",
  "main": {
    "temp": 283.89,
    "feels_like": 283.34,
    "temp_min": 282.62,
    "temp_max": 284.9,
    "pressure": 1006,
    "humidity": 89
  },
  "visibility": 10000,
  "wind": {
    "speed": 4.63,
    "deg": 210
  },
  "clouds": {
    "all": 75
  },
  "dt": 1709178300,
  "sys": {
    "type": 2,
    "id": 2075535,
    "country": "GB",
    "sunrise": 1709189242,
    "sunset": 1709228336
  },
  "timezone": 0,
  "id": 2643743,
  "name": "London",
  "cod": 200
}

This command will decode the base64 string and present the structured JSON output. If you have any further questions or need additional assistance, feel free to ask. We’re here to help!

Kind regards,
Dasha from HiveMQ Team

I’m currently utilizing HiveMQ Edge and HiveMQ Enterprise along with Kafka to collect data. For HiveMQ Edge, I’m employing HTTPS adapters and leveraging an open API to retrieve data, but I’m noticing that the data I receive is encoded in base64. Meanwhile, I’m using Kafka to obtain data and I prefer to receive this data in plaintext.

I’m curious about why the data I receive is encoded in base64.

Additionally, I have a question regarding MQTT’s data transmission capabilities: does MQTT send data in binary or plaintext?