Curl to C#
Curl is shipped by Microsoft as part of Windows 10 and 11.
Curl:
curl -X GET --header "Accept: application/json" "https://localhost:8187/pricechange/test"
C# equivalent:
using System.Net.Http; HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://localhost:8187/pricechange/test"); request.Headers.Add("Accept", "application/json"); HttpResponseMessage response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync();
Comments
Post a Comment