@@ -17,15 +17,15 @@ It's easy to use. just you should install the package on your project from the b
17
17
You have ** 3 ways** to see script result:
18
18
19
19
** 1: Show to the IDE Console**
20
- (e.g. ** httpClient.GenerateCurlInConsole(httpRequestMessage, requestUri, null);** )
20
+ (e.g. ** httpClient.GenerateCurlInConsole(httpRequestMessage, requestUri, null);** )
21
21
22
22
- ** Notice** : when the curl script was written in the console, maybe your ** IDE console** applies ** WordWrap** automatically. you should ** remove enters** from the script.
23
23
24
24
** 2: Write in a File**
25
- (e.g. ** httpClient.GenerateCurlInFile(httpRequestMessage, requestUri, null);** )
25
+ (e.g. ** httpClient.GenerateCurlInFile(httpRequestMessage, requestUri, null);** )
26
26
27
27
** 3: Put it in a String Variable.**
28
- (e.g. ** string curlResult = httpClient.GenerateCurlInString(httpRequestMessage, requestUri, null);** )
28
+ (e.g. ** string curlResult = httpClient.GenerateCurlInString(httpRequestMessage, requestUri, null);** )
29
29
30
30
31
31
- ** Notice** : Parameters of 'requestUri' and 'config' for both of them are optional.
@@ -46,13 +46,13 @@ If you like this project, learn something or you are using it in your applicatio
46
46
### ** Post Method** sample code (it will be written in the ** console** ):
47
47
```
48
48
string requestBody = @"{""name"":""amin"",""requestId"":""10001000"",""amount"":10000}";
49
- string requestUri = "api/test";
49
+ string requestUri = "/ api/test";
50
50
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
51
51
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
52
52
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
53
53
54
54
using var httpClient = new HttpClient();
55
- httpClient.BaseAddress = new Uri("http://localhost:1213");
55
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
56
56
57
57
httpClient.GenerateCurlInConsole(
58
58
httpRequestMessage,
@@ -70,7 +70,7 @@ If you like this project, learn something or you are using it in your applicatio
70
70
### ** Post Method** sample code for FormUrlEncodedContent (it will be written in the ** console** ):
71
71
```
72
72
string requestBody = @"{""name"":""justin"",""requestId"":10001026,""amount"":26000}";
73
- string requestUri = "api/test";
73
+ string requestUri = "/ api/test";
74
74
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
75
75
httpRequestMessage.Content = new FormUrlEncodedContent(new[]
76
76
{
@@ -80,7 +80,7 @@ If you like this project, learn something or you are using it in your applicatio
80
80
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
81
81
82
82
using var httpClient = new HttpClient();
83
- httpClient.BaseAddress = new Uri("http://localhost:1213");
83
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
84
84
85
85
httpClient.GenerateCurlInConsole(
86
86
httpRequestMessage,
@@ -108,12 +108,12 @@ If you like this project, learn something or you are using it in your applicatio
108
108
<amount>240000</amount>
109
109
</Order>";
110
110
111
- var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "api/test");
111
+ var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "/ api/test");
112
112
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
113
113
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
114
114
115
115
using var httpClient = new HttpClient();
116
- httpClient.BaseAddress = new Uri("http://localhost:1213");
116
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
117
117
118
118
httpClient.GenerateCurlInConsole(
119
119
httpRequestMessage,
@@ -136,13 +136,13 @@ If the filename variable is null or empty, then the current date will be set for
136
136
string path = string.Empty;
137
137
string filename = "PostMethodResult" ;
138
138
string requestBody = @"{""name"":""sara"",""requestId"":""10001001"",""amount"":20000}";
139
- string requestUri = "api/test";
139
+ string requestUri = "/ api/test";
140
140
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);
141
141
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
142
142
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
143
143
144
144
using var httpClient = new HttpClient();
145
- httpClient.BaseAddress = new Uri("http://localhost:1213");
145
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
146
146
147
147
httpClient.GenerateCurlInFile(
148
148
httpRequestMessage,
@@ -160,13 +160,13 @@ If the filename variable is null or empty, then the current date will be set for
160
160
161
161
### ** Get Method** sample code (it will be written in the ** console** ):
162
162
```
163
- string requestUri = "api/test";
163
+ string requestUri = "/ api/test";
164
164
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
165
165
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
166
166
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
167
167
168
168
using var httpClient = new HttpClient();
169
- httpClient.BaseAddress = new Uri("http://localhost:1213");
169
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
170
170
171
171
httpClient.GenerateCurlInConsole(
172
172
httpRequestMessage,
@@ -189,13 +189,13 @@ If the filename variable is null or empty, then the current date will be set for
189
189
```
190
190
string path = string.Empty;
191
191
string filename = "GetMethodResult";
192
- string requestUri = "api/test";
192
+ string requestUri = "/ api/test";
193
193
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
194
194
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
195
195
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
196
196
197
197
using var httpClient = new HttpClient();
198
- httpClient.BaseAddress = new Uri("http://localhost:1213");
198
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
199
199
200
200
httpClient.GenerateCurlInFile(
201
201
httpRequestMessage,
@@ -214,13 +214,13 @@ If the filename variable is null or empty, then the current date will be set for
214
214
### ** Put Method** sample code (it will be written in the ** console** ):
215
215
```
216
216
string requestBody = @"{""name"":""jadi"",""requestId"":""10001003"",""amount"":30000}";
217
- string requestUri = "api/test";
217
+ string requestUri = "/ api/test";
218
218
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
219
219
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
220
220
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
221
221
222
222
using var httpClient = new HttpClient();
223
- httpClient.BaseAddress = new Uri("http://localhost:1213");
223
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
224
224
225
225
httpClient.GenerateCurlInConsole(
226
226
httpRequestMessage,
@@ -244,13 +244,13 @@ If the filename variable is null or empty, then the current date will be set for
244
244
string path = string.Empty;
245
245
string filename = "PutMethodResult" ;
246
246
string requestBody = @"{ ""name"" : ""reza"",""requestId"" : ""10001004"",""amount"":40000 }";
247
- string requestUri = "api/test";
247
+ string requestUri = "/ api/test";
248
248
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, requestUri);
249
249
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
250
250
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
251
251
252
252
using var httpClient = new HttpClient();
253
- httpClient.BaseAddress = new Uri("http://localhost:1213");
253
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
254
254
255
255
httpClient.GenerateCurlInFile(
256
256
httpRequestMessage,
@@ -269,13 +269,13 @@ If the filename variable is null or empty, then the current date will be set for
269
269
### ** Patch Method** sample code (it will be written in the ** console** ):
270
270
```
271
271
string requestBody = @"{""name"":""hamed"",""requestId"":""10001005"",""amount"":50000}";
272
- string requestUri = "api/test";
272
+ string requestUri = "/ api/test";
273
273
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
274
274
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
275
275
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
276
276
277
277
using var httpClient = new HttpClient();
278
- httpClient.BaseAddress = new Uri("http://localhost:1213");
278
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
279
279
280
280
httpClient.GenerateCurlInConsole(
281
281
httpRequestMessage,
@@ -299,13 +299,13 @@ If the filename variable is null or empty, then the current date will be set for
299
299
string path = string.Empty;
300
300
string filename = "PatchMethodResult" ;
301
301
string requestBody = @"{ ""name"" : ""zara"",""requestId"" : ""10001006"",""amount"":60000 }";
302
- string requestUri = "api/test";
302
+ string requestUri = "/ api/test";
303
303
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Patch, requestUri);
304
304
httpRequestMessage.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
305
305
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
306
306
307
307
using var httpClient = new HttpClient();
308
- httpClient.BaseAddress = new Uri("http://localhost:1213");
308
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
309
309
310
310
httpClient.GenerateCurlInFile(
311
311
httpRequestMessage,
@@ -324,13 +324,13 @@ If the filename variable is null or empty, then the current date will be set for
324
324
### ** Delete Method** sample code (it will be written in the ** console** ):
325
325
```
326
326
int id = 12;
327
- string requestUri = $"api/test/{id}";
327
+ string requestUri = $"/ api/test/{id}";
328
328
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, requestUri);
329
329
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
330
330
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
331
331
332
332
using var httpClient = new HttpClient();
333
- httpClient.BaseAddress = new Uri("http://localhost:1213");
333
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
334
334
335
335
httpClient.GenerateCurlInConsole(
336
336
httpRequestMessage,
@@ -354,13 +354,13 @@ If the filename variable is null or empty, then the current date will be set for
354
354
string path = string.Empty;
355
355
string filename = "DeleteMethodResult";
356
356
int id = 12;
357
- string requestUri = $"api/test/{id}";
357
+ string requestUri = $"/ api/test/{id}";
358
358
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, requestUri);
359
359
httpRequestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
360
360
httpRequestMessage.Headers.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
361
361
362
362
using var httpClient = new HttpClient();
363
- httpClient.BaseAddress = new Uri("http://localhost:1213");
363
+ httpClient.BaseAddress = new Uri("http://localhost:1213/v1 ");
364
364
365
365
httpClient.GenerateCurlInFile(
366
366
httpRequestMessage,
0 commit comments