HueLibrary.Bridge.HttpPutAsync C# (CSharp) Method

HttpPutAsync() private method

Sends a PUT command via HTTP and returns the response.
private HttpPutAsync ( string commandUrl, string body ) : Task
commandUrl string
body string
return Task
        internal async Task<string> HttpPutAsync(string commandUrl, string body)
        {
            using (var client = new HttpClient())
            {
                Uri uri = new Uri($"http://{UrlBase}{commandUrl}");
                HttpResponseMessage response = await client.PutAsync(uri, new HttpStringContent(body));
                return await response.Content.ReadAsStringAsync();
            }
        }
    }

Usage Example

Exemplo n.º 1
0
 /// <summary>
 /// Attempts to rename the light.
 /// </summary>
 public async Task RenameAsync(string name) =>
 await _bridge.HttpPutAsync($"lights/{Id}", $"{{\"name\":\"{name}\"}}");