I've got a device I'm trying to write a driver for, but I'm running into an issue. I have to use a packet sniffer to figure out the api so I'm running a little blind. Further, the there are some, what I consider, odd parts of the api. Some requests are fully URL encoded; some are partially; and some are not at all. It seems rather random to me.
Where this causes me a problem is here. I have one request where the literal string works in a web browser just fine, but if I try to do it with httpGet, I get an error.
def setupQueue()
{
logDebug("setupQueue()")
params=[
uri: "http://${ipAddress}:80/api/event/modifyQueue?queueId=&subscribe=[{\"path\":\"settings%3A/mediaPlayer/mute\",\"type\":\"item\"},{\"path\":\"settings%3A/mediaPlayer/mute\",\"type\":\"rows\"}]&unsubscribe=[]",
headers: ["Accept":"application/json"],
timeout:10
]
try{
httpGet(params){response->
if(response.status!=200){
logError("Error setting up queue ${response.status}")
} else {
logDebug(response.data)
}
}
}catch(e){
logError("Error ${e.getMessage()}")
}
}
I keep getting this error:
Illegal character in query at index 66: http://XXX.XXX.X.XXX:80/api/event/modifyQueue?queueId=&subscribe=[{"path":"settings%3A/mediaPlayer/mute","type":"item"},{"path":"settings%3A/mediaPlayer/mute","type":"rows"}]&unsubscribe=[]
If I copy the string from the error message, and past it into a web browser, I get a perfect response.
This seems to be directly pointing to the fact that it is not URL encoded because it is complaining about the "{". If I encode it, the device responses that it is an illegal request.
I can't find a way around this one. I tried webSocket, but I honestly don't understand what I'm doing there and just kept getting an error that it was expecting a 101 response but got a 200 response.
Any clarity on this would be appreciated.