public PutAsync ( Uri requestUri, HttpContent content ) : Task |
||
requestUri | Uri | |
content | HttpContent | |
return | Task |
using System.Net.Http; using Newtonsoft.Json; var client = new HttpClient(); var updatedData = new { Id = 1, Name = "Updated Name", Description = "Updated Description" }; var jsonContent = new StringContent(JsonConvert.SerializeObject(updatedData)); var response = await client.PutAsync("https://example.com/api/resources/1", jsonContent);
using System.Net.Http; using System.IO; var client = new HttpClient(); var fileStreamContent = new StreamContent(File.OpenRead(@"C:\example.pdf")); var response = await client.PutAsync("https://example.com/api/resources/1", fileStreamContent);This example sends a PUT request to the endpoint "https://example.com/api/resources/1" with the contents of the file "example.pdf" as the request body. The file data is sent as a stream in the request body. The System.Net.Http.HttpClient class is part of the .NET Standard Library.
public PutAsync ( Uri requestUri, HttpContent content ) : Task |
||
requestUri | Uri | |
content | HttpContent | |
return | Task |