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

PutAsync() public method

public PutAsync ( string requestUri, HttpContent content, CancellationToken cancellationToken ) : Task
requestUri string
content HttpContent
cancellationToken CancellationToken
return Task
        public Task<HttpResponseMessage> PutAsync(string requestUri, HttpContent content,
            CancellationToken cancellationToken)
        {
            return PutAsync(CreateUri(requestUri), content, cancellationToken);
        }

Same methods

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

Usage Example

コード例 #1
0
        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