I'm trying to get a json response back from the Philips hue after I complete a PUT request. The Philips hue has a build in web server command line, when I send a basic json message like "{"on":True}" using the hue web interface I get a json response back telling me that the request was a success. The message looks like this:
"[
{
"success": {
"/lights/1/state/on": true
}
}
]"
Right now when I send a command to the hue via my setup below, I always get a TRUE .IsSuccessStatusCode (I'm assuming becasue the message was recieved by the hue?) even if I send some json that should cause an error. Example; I could use the json {"on":Cause an error} and still get a TRUE.
So I'm trying to figure out how to get the above json response back from the hue after I've sent a PUT. Below is the code I'm using.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
async static void setLight()
{
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage();
String myJson = "{\"on\":false}";
var content = new StringContent(myJson, Encoding.UTF8, "application/json");
HttpResponseMessage returnStatement = await client.PutAsync("http://192.168.1.3/api/139f12ce32a30c473368dbe25f6586b/lights/1/state", content);
Console.WriteLine(returnStatement.IsSuccessStatusCode);
}