Binary raw data at NoteHub

I am trying to send the note with the binary data.

  uint8_t data[200]; 
  // data is populated by some other code
  const uint32_t notecard_binary_area_offset = 0;
  NoteBinaryStoreTransmit(reinterpret_cast<uint8_t *>(data), data_len, data_len + 100, notecard_binary_area_offset);

  if (J *req = notecard.newRequest("note.add"))
  {
    JAddStringToObject(req, "file", "binary.qo");
    JAddBoolToObject(req, "binary", true);
    JAddBoolToObject(req, "live", true);
    if (!notecard.sendRequest(req)) {
      NoteBinaryStoreReset();
    } 
  }

The binary data is received at the Notehub as a base64 encoded “payload”.

{
  "event": "be2c1405-0d95-8405-b97b-bf1e7aa3ea3e",
  "when": 1750951308,
  "file": "binary.qo",
  "body": {},
  "payload": "o2lwcm90ZWN0ZWSiY3ZlcmJ2MWNhbGdlSFMyNTZpc2lnbmF0dXJleEBiYTNjNjFhYzdmZDYxYzRiODFlMWQ0NjNkMThmNmIwOGU0ZmZhY2U3ZTBiMzE1MjhkMzIzZGFkZTVjZjI0MGY4Z3BheWxvYWSla2RldmljZV9uYW1lcWFjOjg3OmEzOjBhOjJkOjFia2RldmljZV90eXBlblhJQU8gQkxFIFNlbnNla2ludGVydmFsX21z+UkAZ3NlbnNvcnOBomRuYW1la3RlbXBlcmF0dXJlZXVuaXRzZ2NlbGNpdXNmdmFsdWVzn/pByZma/w==",
  "session": "ea9efb3a-b301-446f-a4dd-1ef8752f02fa",
  "transport": "wifi",
...
}

How can I get the binary raw data that I need to POST to an external web service using a route? The web service only accepts the binary data not the base64 encoded one.

Hi @yokonav

When binary data is transferred from the Notecard to Notehub, it is encoded as a base64 string, titled payload. You cannot send raw bytes unfortunately.

My suggestion would be to use an intermediate web service to transform the base64 data into a format that can be sent to your application.

Thanks,
Alex

1 Like