Skip to content

GetStarted

mozhganEtaati edited this page Oct 14, 2025 · 6 revisions

It’s easy to use HttpClientToCurl!
You need to install the package in your .NET project and use the sample codes below to see how to call and work with the extensions.


Installation

To add the package to your project from NuGet, use the following command:

dotnet add package HttpClientToCurl

Or visit the NuGet page here: HttpClientToCurl


Quick Start

You can see quick samples of getting curl from HttpClient or HttpRequestMessage in .NET below:

HttpClient Extension

You have 3 Quick ways to see the generated curl script result from HttpClient:

Put it in a string variable

string curlResult = httpClientInstance.GenerateCurlInString(httpRequestMessage);

Show it in the IDE console

httpClientInstance.GenerateCurlInConsole(httpRequestMessage);

Write it into a file

httpClientInstance.GenerateCurlInFile(httpRequestMessage);

Additionally, there is another overload option for adding everything as plain:

httpClientInstance.GenerateCurlInString(yourHttpMethod, "yourRequestUri", "yourHeader", "yourContent");

HttpRequestMessage Extension

You have 3 Quick ways to see the generated curl script result from HttpRequestMessage:

Put it in a string variable

string curlResult = httpRequestMessageInstance.GenerateCurlInString(new Uri("http://localhost:1213/v1/"));

Show it in the IDE console

httpRequestMessageInstance.GenerateCurlInConsole(new Uri("http://localhost:1213/v1/"));

Write it into a file

httpRequestMessageInstance.GenerateCurlInFile(new Uri("http://localhost:1213/v1/"));
Clone this wiki locally