using System.Net.Http; HttpClient client = new HttpClient(); string response = await client.GetStringAsync("https://example.com/api/data");
using System.Net.Http; using System.Net.Http.Headers; using System.Text.Json; HttpClient client = new HttpClient(); var data = new { id = 123, name = "John Smith" }; var json = JsonSerializer.Serialize(data); HttpContent content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("https://example.com/api/data", content); if (response.IsSuccessStatusCode) { string responseJson = await response.Content.ReadAsStringAsync(); var result = JsonSerializer.DeserializePackage library: System.Net.Http, which is typically included with the .NET framework.(responseJson); }