Problem sending JSON as Data body over socket API

I would like to upload data from my embedded device (Pycom GPY) to the Hologram cloud service in JSON format. I formatted the data as JSON and suck it in the data field of the Hologram JSON format, like so.


I can run this message simulator and everything works as expected. However, I get a return value of [2,0] when sending the exact same over the socket API from my GPy.

Is there a way to send JSON in the data field of the socket API?

Try escaping your quotes in the data block ( " to \") like:


I havent tested it but I’m guessing thats the problem

That didn’t work, but it did give me the idea to remove the outer quotes around the inner JSON, like so:


That at least made it to the Hologram Dashboard. Nothing shows up in the “Data” field when looking at it through the web interface. It does show up in the REST API when getting the device messages. I’m not sure why Hologram is formatting the data this way, but at least I have a way to get it.

     "id": 16435879,
     "logged": "2018-12-18 20:30:45.855792",
     "orgid": 19345,
      "deviceid": 189001,
      "record_id": "c5f8fcee-0303-11e9-ae55-0242ac120002",
      "device_metadata": "{}",
      "data": "{\"received\": \"2018-12-18T20:30:35.244991\", \"authtype\": \"psk\", \"tags\": [\"_SOCKETAPI_\", \"_DEVICE_189001_\", \"_JSONSTRING_\", \"SOMETHING\"], \"timestamp\": \"0\", \"device_name\": \"Pilot (00000)\", \"errorcode\": 0, \"source\": \"devicekey\", \"device_metadata\": {}, \"record_id\": \"c5f8fcee-0303-11e9-ae55-0242ac120002\", \"data\": \"{\\\"data\\\": \\\"1234567890\\\"}\", \"device_id\": 189001}",
      "matched_rules": [],
      "tags": [

Nice! glad that worked, also a good idea (although I’m surprised my idea didnt also work, I hope its possible to send strings that look like JSON but may not be JSON and include { and " characters).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.