Help on getting data from http response

Avatar
  • updated
  • Under review

I'm  trying to get data from the respnonse "actualvolume" 

I've been exploring the forum here but i can't figure out what i'm doing wrong.


Parse type: Jhson

I get this response:

{"?xml":{"@version":"1.0","@encoding":"UTF-8"},"volume":{"@deviceID":"C4F312D5994F","targetvolume":"16","actualvolume":"16","muteenabled":"false"}}

Image 2282

Image 2283

Image 2284


Image 2288

Avatar
ComfortClick Support

Hello,


Seems you were using wrong token name, you should be using XML parser and token name should be volume.actualvolume. Did you try this as well?


Best regards.

Avatar
Ricardo Pinto

Can it be a bOS bug?

First: It doesn't make sense that the Response Data updates, and the Response Data Xml to Json doesn't... as it's supposed to be updated according to the Response Data received...everytime the Response Data changes, the Xml to Json is supposed to change also.

Second: It doesn't make sense the Tokens don't extract anything, because if we check the Json response in any online expression tester, the values are correct:

Using JSONPath Expression Tester web service (https://jsonpath.curiousconcept.com/), which is the one I use all the time to test the expressions before getting them on bOS, if you past the following expression:

{ 
   "?xml":{ 
      "@version":"1.0",
      "@encoding":"UTF-8"
   },
   "volume":{ 
      "@deviceID":"C4F312D5994F",
      "targetvolume":"16",
      "actualvolume":"16",
      "muteenabled":"false"
   }
}

And place volume.actualvolume on the Expression, you get this as an answer:

[ 
"16"
]

BUT, only by using the called JSONPath 0.2.5 or above... below that implementation, the response is empty.

bOS team, can you help us out here?

Avatar
Dave De Busschere
Quote from Ricardo Pinto

And if you change back the parser to Json? The values show empty again?

Nothing changes

I turned the volume with the Bose remote up to 12, when I push the button in Bos Theme "Get current volume" the response data changes to 12 BUT the response Data Xml to Json remains on the 10!!!

I Get a reading (communication between the Bose and Bos). 


Avatar
Ricardo Pinto

And if you change back the parser to Json? The values show empty again?

Avatar
Dave De Busschere
Quote from Ricardo Pinto

Ah BTW, can you change the parser type to XML on the device?

And post again the responses?


Avatar
Ricardo Pinto

Ah BTW, can you change the parser type to XML on the device?

And post again the responses?

Avatar
Ricardo Pinto

Can you do a little test?

Create 2x Double values:

Name: Target Volume double

Token name: targetvolume

Name: Actual Volume double

Token name: actualvolume

Create 2x String values:

Name: Target Volume string

Token name: targetvolume

Name: Actual Volume string

Token name: actualvolume

I tested the response on several online converters / parsers, and I believe that:

If we keep the <?xml version...?> part, the correct token name should be volume.targetvolume and volume.actualvolume

{ 
    "?xml":{ 
        "@version":"1.0",
        "@encoding":"UTF-8"
    },
    "volume":{ 
        "@deviceID":"C4F312D5994F",
        "targetvolume":"16",
        "actualvolume":"16",
        "muteenabled":"false"
    }
}

But if you remove the <?xml version...?>, the correct token name is actually only targetvolume and actualvolume, just the text, with no "." after or before.

{
   "deviceID": "C4F312D5994F",
   "targetvolume": "10",
   "actualvolume": "10",
   "muteenabled": "false"
}

Can you test the token names only with targetvolume and actualvolume without any dots?

The double and strings values, are just to test the correct format. I supposed that the values from volume are coming as double values, but you can test both

Avatar
Dave De Busschere
Quote from Ricardo Pinto

Hi,

I read the Bose API documentation, and they say that when using GET and POST commands, the data must be formatted in correct XML. So far so good.

But the point here, is that you get the correct response from the unit on the command. But when using the token, it doesn't extract the value. Right now I'm only concerned about the simple GET commands, and as soon as fixed move on to the POST data commands.

If you open the following URL in your browser http://192.168.2.209:8090/volume do you get an answer?

I suppose you get something like:

<?xml version="1.0" ?>
<volume deviceID="$MACADDR">
<targetvolume>$INT</targetvolume>
<actualvolume>$INT</actualvolume>
<muteenabled>$BOOL</muteenabled>
</volume>


Right?

Please copy past your XML answer here. The one you get from the browser, and the one you get on bOS command from "Response Data".

browser answer:

Bos answer:



Avatar
Ricardo Pinto

Hi,

I read the Bose API documentation, and they say that when using GET and POST commands, the data must be formatted in correct XML. So far so good.

But the point here, is that you get the correct response from the unit on the command. But when using the token, it doesn't extract the value. Right now I'm only concerned about the simple GET commands, and as soon as fixed move on to the POST data commands.

If you open the following URL in your browser http://192.168.2.209:8090/volume do you get an answer?

I suppose you get something like:

<?xml version="1.0" ?>
<volume deviceID="$MACADDR">
<targetvolume>$INT</targetvolume>
<actualvolume>$INT</actualvolume>
<muteenabled>$BOOL</muteenabled>
</volume>


Right?

Please copy past your XML answer here. The one you get from the browser, and the one you get on bOS command from "Response Data".

Avatar
Dave De Busschere

When I look at the Bose website (special-types) it looks like the response is a flag?

sorry for being a amateur, but when I able to retrieve the responsdata and publish it in bos I'm on a go.

https://developer.bose.com/special-types