@@ -14,17 +14,21 @@ It's easy to use. just you should install the package on your project from the b
1414
1515[ Nuget Package Address] ( https://www.nuget.org/packages/HttpClientToCurl/ )
1616
17- You have ** 2 ways** to see script results :
17+ You have ** 3 ways** to see script result :
1818
19- ** 1- Console**
19+ ** 1: Show to the IDE Console**
2020(e.g. ** httpClient.GenerateCurlInConsole(httpRequestMessage, requestUri, null);** )
2121
2222- ** Notice** : when the curl script was written in the console, maybe your ** IDE console** applies ** WordWrap** automatically. you should ** remove enters** from the script.
2323
24- ** 2- File**
24+ ** 2: Write in a File**
2525(e.g. ** httpClient.GenerateCurlInFile(httpRequestMessage, requestUri, null);** )
2626
27- (Parameters of 'requestUri' and 'config' for both of them are optional.)
27+ ** 3: Put it in a String Variable.**
28+ (e.g. ** string curlResult = httpClient.GenerateCurlInString(httpRequestMessage, requestUri, null);** )
29+
30+
31+ - ** Notice** : Parameters of 'requestUri' and 'config' for both of them are optional.
2832
2933I will be happy say me if you have any feedback and your solution to improve the code and also if you find a problem.
3034also, I will be extremely happy if you contribute to the implementation and improvement of the project.
@@ -35,11 +39,13 @@ also, I will be extremely happy if you contribute to the implementation and impr
3539
3640If you like this project, learn something or you are using it in your applications, please give it a star. Thanks!
3741
38- ## ** How to use HttpClientToCurlGenerator** :
42+ ## ** How to use HttpClientToCurlGenerator Extensions** :
43+
44+ ** You can see more samples in FunctionalTest Directory.**
3945
4046### ** Post Method** sample code (it will be written in the ** console** ):
4147```
42- string requestBody = @"{ ""name"" : ""amin"",""requestId"" : ""10001000"",""amount"":10000 }";
48+ string requestBody = @"{""name"": ""amin"",""requestId"": ""10001000"",""amount"":10000}";
4349 string requestUri = "api/test";
4450 var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
4551 httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
@@ -63,7 +69,7 @@ If you like this project, learn something or you are using it in your applicatio
6369
6470### ** Post Method** sample code for FormUrlEncodedContent (it will be written in the ** console** ):
6571```
66- string requestBody = @"{ ""name"" : ""justin"",""requestId"" : 10001026,""amount"":26000 }";
72+ string requestBody = @"{""name"": ""justin"",""requestId"": 10001026,""amount"":26000}";
6773 string requestUri = "api/test";
6874 var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
6975 httpRequestMessage.Content = new FormUrlEncodedContent(new[]
@@ -89,28 +95,6 @@ If you like this project, learn something or you are using it in your applicatio
8995 // Call PostAsync => await client.PostAsync(requestUri, httpRequest.Content);
9096```
9197
92- ### ** Post Method** sample code without set the requestUri (it will be written in the ** console** ):
93- ```
94- string requestBody = @"{ ""name"" : ""soozan"",""requestId"" : ""10001027"",""amount"":27000 }";
95- var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "api/test");
96- httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
97- httpRequestMessage.Headers.Add("Authorization", Guid.NewGuid().ToString());
98-
99- using var httpClient = new HttpClient();
100- httpClient.BaseAddress = new Uri("http://localhost:1213");
101-
102- httpClient.GenerateCurlInConsole(
103- httpRequestMessage,
104- config: config =>
105- {
106- config.TurnOn = true;
107- config.NeedAddDefaultHeaders = true;
108- config.EnableCodeBeautification = false;
109- });
110-
111- // Call PostAsync => await client.PostAsync(httpRequestMessage.RequestUri?.ToString(), httpRequest.Content);
112- ```
113-
11498### ** Post Method** sample code for xml (it will be written in the ** console** ):
11599
116100```
@@ -151,7 +135,7 @@ If the filename variable is null or empty, then the current date will be set for
151135```
152136 string path = string.Empty;
153137 string filename = "PostMethodResult" ;
154- string requestBody = @"{ ""name"" : ""sara"",""requestId"" : ""10001001"",""amount"":20000 }";
138+ string requestBody = @"{""name"": ""sara"",""requestId"": ""10001001"",""amount"":20000}";
155139 string requestUri = "api/test";
156140 var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
157141 httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
@@ -229,7 +213,7 @@ If the filename variable is null or empty, then the current date will be set for
229213
230214### ** Put Method** sample code (it will be written in the ** console** ):
231215```
232- string requestBody = @"{ ""name"" : ""jadi"",""requestId"" : ""10001003"",""amount"":30000 }";
216+ string requestBody = @"{""name"": ""jadi"",""requestId"": ""10001003"",""amount"":30000}";
233217 string requestUri = "api/test";
234218 var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
235219 httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
@@ -284,7 +268,7 @@ If the filename variable is null or empty, then the current date will be set for
284268
285269### ** Patch Method** sample code (it will be written in the ** console** ):
286270```
287- string requestBody = @"{ ""name"" : ""hamed"",""requestId"" : ""10001005"",""amount"":50000 }";
271+ string requestBody = @"{""name"": ""hamed"",""requestId"": ""10001005"",""amount"":50000}";
288272 string requestUri = "api/test";
289273 var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
290274 httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
@@ -392,6 +376,6 @@ If the filename variable is null or empty, then the current date will be set for
392376 // Call DeleteAsync => await client.DeleteAsync(requestUri);
393377```
394378
395- ** You can see more samples in UnitTest files in Project .**
379+ ** You can see more samples in FunctionalTest Directory .**
396380
397381I hope enjoying this extension in your projects.
0 commit comments