System.Net.Http.HttpClient.PutAsync C# (CSharp) Method

PutAsync() public method

public PutAsync ( Uri requestUri, HttpContent content ) : Task
requestUri Uri
content HttpContent
return Task
        public Task<HttpResponseMessage> PutAsync(Uri requestUri, HttpContent content)
        {
            return PutAsync(requestUri, content, CancellationToken.None);
        }

Same methods

HttpClient::PutAsync ( Uri requestUri, HttpContent content, CancellationToken cancellationToken ) : Task
HttpClient::PutAsync ( string requestUri, HttpContent content ) : Task
HttpClient::PutAsync ( string requestUri, HttpContent content, CancellationToken cancellationToken ) : Task

Usage Example

        private static async Task AlbumsControllerTest(HttpClient client)
        {
            // create album
            await client.PostAsync("Albums/Create",
                new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("title", "album 009") }));
            await client.PostAsync("Albums/Create",
                new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("title", "album 010") }));

            // get all albums
            Console.WriteLine(await client.GetStringAsync("Albums/All"));

            // update album
            await client.PutAsync("Albums/Update",
                new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair<string, string>("id", "2"),
                    new KeyValuePair<string, string>("year", "2014"),
                    new KeyValuePair<string, string>("producer", "gosho ot pochivka")
                }));

            // delete album 
            await client.DeleteAsync("Albums/Delete/1");

            // add song to album
            await client.PutAsync("Albums/AddSong?albumId=2&songId=2", null);

            // add artist to album
            await client.PutAsync("Albums/AddArtist?albumId=2&artistId=2", null);
        }
All Usage Examples Of System.Net.Http.HttpClient::PutAsync