The Things Network V3 - API: Bad JSON Format

Hi!

When hitting: https://nam1.cloud.thethings.network/api/v3/as/applications/app-id/packages/storage/uplink_message?limit=2

I receive the following body:

{"result":{"end_device_ids":{"device_id":"t-beam-11-weather-station","application_ids":{"application_id":"apartment-weather-station"},"dev_eui":"000479C57080D2EE","dev_addr":"260C5681"},"received_at":"2021-08-29T00:01:04.680953136Z","uplink_message":{"f_port":1,"f_cnt":429,"frm_payload":"/3//fw==","decoded_payload":{"message":{"degreesC":99.951171875,"humidity":99.951171875}},"rx_metadata":[{"gateway_ids":{"gateway_id":"a84041ffff1ede24tomas","eui":"A84041FFFF1EDE24"},"timestamp":1356767240,"rssi":-50,"channel_rssi":-50,"snr":12.8,"channel_index":4}],"settings":{"data_rate":{"lora":{"bandwidth":125000,"spreading_factor":10}},"coding_rate":"4/5","frequency":"904700000","timestamp":1356767240},"received_at":"2021-08-29T00:01:04.465791633Z","consumed_airtime":"0.329728s","network_ids":{"net_id":"000013","tenant_id":"ttn","cluster_id":"ttn-nam1"}}}}
{"result":{"end_device_ids":{"device_id":"t-beam-11-weather-station","application_ids":{"application_id":"apartment-weather-station"},"dev_eui":"000479C57080D2EE","dev_addr":"260C5681"},"received_at":"2021-08-29T00:02:23.959239182Z","uplink_message":{"f_port":1,"f_cnt":432,"frm_payload":"/3//fw==","decoded_payload":{"message":{"degreesC":99.951171875,"humidity":99.951171875}},"rx_metadata":[{"gateway_ids":{"gateway_id":"a84041ffff1ede24tomas","eui":"A84041FFFF1EDE24"},"timestamp":1436054746,"rssi":-107,"channel_rssi":-107,"snr":-8,"channel_index":6}],"settings":{"data_rate":{"lora":{"bandwidth":125000,"spreading_factor":10}},"coding_rate":"4/5","frequency":"905100000","timestamp":1436054746},"received_at":"2021-08-29T00:02:23.744378167Z","consumed_airtime":"0.329728s","network_ids":{"net_id":"000013","tenant_id":"ttn","cluster_id":"ttn-nam1"}}}}

As you can see between every {"result": [...]} there are no commas and no brackets surrounding it, so it fails to comply with JSON standard and it fails when trying to parse it as is.

It’s an event stream, each line is a separate entity that is targeted towards Server Side Events like the console log etc.

It is a PitA for static downloads but I solve it like this:

1 Like

Yeap! I did exactly the same. Thanks!

image