API response format

Hello there,

I have an emergency lighting battery testing device connected to Thinger.io. The data stored in the cloud platform would transfer to other platform through API. It works well before. But, recently the data in the cloud platform can’t be transferred to my other platform. I tested the API by using the get function in postman. The response result from API is text format but not in Json format as shown below.

Anyone have same experience?

Thanks

Hi!

the old endpoint v2 version was returning a JSON object with the result from the device, i.e,

{
   "out" : "Connected"
}

However, in the v3 we have removed the unnecesary "out", so a device returning complex objects are property returned in the API without extra and unexpected fields like out, i.e.:

{
   "temperature": 22.4,
   "humidity" : 33.5
}

So, if you want to still using the old format, just change v3 to v2 in the request url. But take into account that the v3 is already returning a JSON, as "Connected" is a valid JSON document.

If you want to use the v3 but need a JSON object to be returned, you can also redefine your resource to provide the required format by your backend, i.e.:

thinger["LoraStatus"] >> [](pson& out){
    out["state"] = "connected";
    out["sent"] = ...
    out["received"] = ...
};

It will be formated in the API as:

{
    "state" : "connected",
    "sent" : 222,
    "received" : 668
}

Hope it helps!

Hi Alvarolb,

It works now. Thanks a lot for your help.