Http request with homey pro 2023

Good morning,
I got my new homey (2023) this week and currently, I´m checking, which apps are running and which apps are not running, before I start the migration.
I query the oillevel from an API with the HTTP request-app. I have learned, there are some other possibilities with logic & advanced flows.
I tried the “new” way, but it does not work.
I assume, the format of the answer is the problem - there are backslashes in the answer but I have no idea to fix the problem.

The answer of the post:
“{"DeviceResponse":[{"DeviceID":"5163306","DeviceName":"Gerhard Berger","Medium":"Heizöl","LastUpdate":"8/2/2023 8:00:02 AM","MaxVolume":"980","ActualVolume":"850","ActualVolumePercent":"87","Battery":"2.9","Temperature":"71","MessData":"39"}]}”

Do you have an idea, how I can handle this issue?

The interessting thing - in the post, the backslashes are not displayed:
image

Thanks & cheers
Gerhard

The \ indicates the next " is a part of the data and not a delimiter (escape sequence). They might just be the way the data is formatted so it shows in the time line.

What exactly is the problem it is causing you?

I get the error: obj needs to be an object

My test flow is this:

I have another HTTP-Request running, and it works with the advanced flow.

I encountered similar problem the other day, and I had to add another square bracket “[” and “]” arount the data to be fully identified as an object.

How have you inserted the square brackets?

The API server returns the data double-encoded:

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Encoding: gzip
Content-Length: 312
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Aug 2023 06:15:19 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-IIS/10.0
Vary: Accept-Encoding
X-Powered-By: ASP.NET

"{\"DeviceResponse\":[{\"DeviceID\":\"5163306\",\"DeviceName\":\"Gerhard Berger\",\"Medium\":\"Heizöl\",\"LastUpdate\":\"8/2/2023 8:00:02 AM\",\"MaxVolume\":\"980\",\"ActualVolume\":\"850\",\"ActualVolumePercent\":\"87\",\"Battery\":\"2.9\",\"Temperature\":\"71\",\"MessData\":\"39\"}]}"

E.g script like:

const string = “[”+data+“]”;

Ok, thanks!
`till now, I have no script in place - so a new experience.
That means, I do the http-call, afterwards I call a script, which insert the square brackets, write the result in the text variable and then I parse it or I assume, it´s also possible to do all in a script.
Maybe you have an script example for me - would be great!

I think maybe you would try to just add the square brackets to the answer tag, before parse it to JSON?

The issue here isn’t missing square brackets, it’s an incorrect server response.

I did a test, from the parse-card with square brackets in different formats, and it doesn´t work.

When I replace the backslashes and the first and last double quote, it works.

{“DeviceResponse”:[{“DeviceID”:“5163306”,“DeviceName”:“Gerhard Berger”,“Medium”:“Heizöl”,“LastUpdate”:“8/2/2023 8:00:02 AM”,“MaxVolume”:“980”,“ActualVolume”:“850”,“ActualVolumePercent”:“87”,“Battery”:“2.9”,“Temperature”:“71”,“MessData”:“39”}]}

I think, this can be handled with a script and not with a logic-card or is there a possibility?