⚠ Deprecated: Other
Commits have been migrated to the official repository. Please use the official package: Curl.HttpClient.Converter
Suggested alternative: Curl.HttpClient.Converter
A cURL parser and C# code converter based on curl-to-csharp project for .NET Core. Supported platforms: - For ASP.NET Core 5, .NET 5 - For ASP.NET Core 3, .NET Core 3.0
$ dotnet add package CurlParser.CSharpA cURL parser and C# code converter based on curl-to-csharp project for .NET Core.
Supported platforms:
Install with NuGet
dotnet add package CurlParser.CSharp
var input = @"curl https://sentry.io/api/0/projects/1/groups/?status=unresolved -d '{""status"": ""resolved""}' -H 'Content-Type: application/json' -u 'username:password' -H 'Accept: application/json' -H 'User-Agent: curl/7.60.0'";
var output = new Converter().Parse(input, 10);
Console.WriteLine(output.Data);
// Output:
/*
// In production code, don't destroy the HttpClient through using, but better reuse an existing instance
// https://www.aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://sentry.io/api/0/projects/1/groups/?status=unresolved"))
{
request.Headers.TryAddWithoutValidation("Accept", "application/json");
request.Headers.TryAddWithoutValidation("User-Agent", "curl/7.60.0");
var base64authorization = Convert.ToBase64String(Encoding.ASCII.GetBytes("username:password"));
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {base64authorization}");
request.Content = new StringContent("{\"status\": \"resolved\"}");
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
var response = await httpClient.SendAsync(request);
}
}
*/