Hi @Petr,
The main issue here is that the response type is not application/json
but text/event-stream
, which is a stream of JSON formatted messages (separated by empty lines). Here is an example response (quoted from the docs):
{"result":{"end_device_ids":{"device_id":"dev1","application_ids":{"application_id":"app1"},"dev_eui":"1111111111111111","dev_addr":"014457CB"},"received_at":"2020-08-24T10:08:44.868680817Z","uplink_message":{"session_key_id":"AXPoziFRvbcEguvZQoCCZw==","f_port":10,"f_cnt":43,"frm_payload":"AQoBCgEKAQo=","rx_metadata":[{"gateway_ids":{"gateway_id":"gtw1"},"time":"2020-08-24T10:08:43.385687165Z","timestamp":3313328983,"uplink_token":"ChIKEAoEZ3R3MRIIEREREREREREQ18b1qwwaDAiso476BRDl6YiuAiDYl7COt2A="}],"settings":{"data_rate":{"lora":{"bandwidth":125000,"spreading_factor":12}},"coding_rate":"4/5","frequency":"868100000","timestamp":3313328983,"time":"2020-08-24T10:08:43.385687165Z"},"received_at":"2020-08-24T10:08:44.634338856Z"}}}
{"result":{"end_device_ids":{"device_id":"dev1","application_ids":{"application_id":"app1"},"dev_eui":"1111111111111111","dev_addr":"014457CB"},"received_at":"2020-08-24T10:08:49.144907967Z","uplink_message":{"session_key_id":"AXPoziFRvbcEguvZQoCCZw==","f_port":10,"f_cnt":44,"frm_payload":"AQoBCgEKAQo=","rx_metadata":[{"gateway_ids":{"gateway_id":"gtw1"},"time":"2020-08-24T10:08:48.891099194Z","timestamp":3318834395,"uplink_token":"ChIKEAoEZ3R3MRIIEREREREREREQ28nFrgwaDAiwo476BRCoqe67AyD47sfPy2A="}],"settings":{"data_rate":{"lora":{"bandwidth":125000,"spreading_factor":12}},"coding_rate":"4/5","frequency":"868100000","timestamp":3318834395,"time":"2020-08-24T10:08:48.891099194Z"},"received_at":"2020-08-24T10:08:48.931407608Z"}}}
Attempting to parse this as a JSON object will raise the error message that you encounter.
Note that the default response message contains a lot of fields for the uplink message. You can limit the fields that are returned by specifying field mask paths in the request, e.g.:
curl -G "https://eu1.cloud.thethings.network/api/v3/as/applications/app1/packages/storage/uplink_message" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: text/event-stream" \
-d "limit=10" \
-d "field_mask=up.uplink_message.f_cnt,up.uplink_message.frm_payload,up.uplink_message.decoded_payload"
See also the documentation for more info on how to use the HTTP API to retrieve uplink messages persisted in the Storage Integration. Hope this helps!