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

Popular posts from this blog

Upgrading to .NET8 from desktop versions 4.8.X

GHL Chat Bots for Webpage

GHL > Set website so shorter URL address