public async Task<bool> RegisterAsync()
{
try
{
using (var client = new HttpClient())
{
string id = new Random().Next().ToString();
var response = await client.PostAsync(new Uri($"http://{Ip}/api"),
new HttpStringContent($"{{\"devicetype\":\"HueLightController#{id}\"}}"));
string content = await response.Content.ReadAsStringAsync();
JArray json = JArray.Parse(content);
if (null != json.First["success"])
{
UserId = json.First["success"]["username"].ToString();
return true;
}
}
}
catch (Exception)
{
return false;
}
return false;
}