@@ -261,6 +261,35 @@ public static RestRequest AddOrUpdateParameters(this RestRequest request, IEnume
261
261
return request ;
262
262
}
263
263
264
+ // TODO: Three methods below added for binary compatibility with v108. Remove for the next major release.
265
+ // In addition, both contentType and options parameters should get default values.
266
+
267
+ public static RestRequest AddFile (
268
+ this RestRequest request ,
269
+ string name ,
270
+ string path ,
271
+ string ? contentType = null
272
+ )
273
+ => request . AddFile ( FileParameter . FromFile ( path , name , contentType ) ) ;
274
+
275
+ public static RestRequest AddFile (
276
+ this RestRequest request ,
277
+ string name ,
278
+ byte [ ] bytes ,
279
+ string filename ,
280
+ string ? contentType = null
281
+ )
282
+ => request . AddFile ( FileParameter . Create ( name , bytes , filename , contentType ) ) ;
283
+
284
+ public static RestRequest AddFile (
285
+ this RestRequest request ,
286
+ string name ,
287
+ Func < Stream > getFile ,
288
+ string fileName ,
289
+ string ? contentType = null
290
+ )
291
+ => request . AddFile ( FileParameter . Create ( name , getFile , fileName , contentType ) ) ;
292
+
264
293
/// <summary>
265
294
/// Adds a file parameter to the request body. The file will be read from disk as a stream.
266
295
/// </summary>
@@ -274,8 +303,8 @@ public static RestRequest AddFile(
274
303
this RestRequest request ,
275
304
string name ,
276
305
string path ,
277
- string ? contentType = null ,
278
- FileParameterOptions ? options = null
306
+ string ? contentType ,
307
+ FileParameterOptions ? options
279
308
)
280
309
=> request . AddFile ( FileParameter . FromFile ( path , name , contentType , options ) ) ;
281
310
@@ -294,8 +323,8 @@ public static RestRequest AddFile(
294
323
string name ,
295
324
byte [ ] bytes ,
296
325
string filename ,
297
- string ? contentType = null ,
298
- FileParameterOptions ? options = null
326
+ string ? contentType ,
327
+ FileParameterOptions ? options
299
328
)
300
329
=> request . AddFile ( FileParameter . Create ( name , bytes , filename , contentType , options ) ) ;
301
330
@@ -314,8 +343,8 @@ public static RestRequest AddFile(
314
343
string name ,
315
344
Func < Stream > getFile ,
316
345
string fileName ,
317
- string ? contentType = null ,
318
- FileParameterOptions ? options = null
346
+ string ? contentType ,
347
+ FileParameterOptions ? options
319
348
)
320
349
=> request . AddFile ( FileParameter . Create ( name , getFile , fileName , contentType , options ) ) ;
321
350
@@ -368,7 +397,7 @@ public static RestRequest AddStringBody(this RestRequest request, string body, D
368
397
/// <param name="contentType">Content type of the body</param>
369
398
/// <returns></returns>
370
399
public static RestRequest AddStringBody ( this RestRequest request , string body , string contentType )
371
- => request . AddParameter ( new BodyParameter ( "" , body , Ensure . NotEmpty ( contentType , nameof ( contentType ) ) ) ) ;
400
+ => request . AddParameter ( new BodyParameter ( body , Ensure . NotEmpty ( contentType , nameof ( contentType ) ) ) ) ;
372
401
373
402
/// <summary>
374
403
/// Adds a JSON body parameter to the request
@@ -379,7 +408,7 @@ public static RestRequest AddStringBody(this RestRequest request, string body, s
379
408
/// <returns></returns>
380
409
public static RestRequest AddJsonBody < T > ( this RestRequest request , T obj , string contentType = ContentType . Json ) where T : class {
381
410
request . RequestFormat = DataFormat . Json ;
382
- return obj is string str ? request . AddStringBody ( str , DataFormat . Json ) : request . AddParameter ( new JsonParameter ( "" , obj , contentType ) ) ;
411
+ return obj is string str ? request . AddStringBody ( str , DataFormat . Json ) : request . AddParameter ( new JsonParameter ( obj , contentType ) ) ;
383
412
}
384
413
385
414
/// <summary>
@@ -396,7 +425,7 @@ public static RestRequest AddXmlBody<T>(this RestRequest request, T obj, string
396
425
397
426
return obj is string str
398
427
? request . AddStringBody ( str , DataFormat . Xml )
399
- : request . AddParameter ( new XmlParameter ( "" , obj , xmlNamespace , contentType ) ) ;
428
+ : request . AddParameter ( new XmlParameter ( obj , xmlNamespace , contentType ) ) ;
400
429
}
401
430
402
431
/// <summary>
0 commit comments