@@ -304,14 +304,16 @@ public static RestRequest AddFile(
304
304
public static RestRequest AddBody ( this RestRequest request , object obj , string ? contentType = null ) {
305
305
if ( contentType == null ) {
306
306
return request . RequestFormat switch {
307
- DataFormat . Json => request . AddJsonBody ( obj , contentType ?? ContentType . Json ) ,
308
- DataFormat . Xml => request . AddXmlBody ( obj , contentType ?? ContentType . Xml ) ,
309
- _ => request . AddParameter ( new BodyParameter ( "" , obj . ToString ( ) ! , contentType ?? ContentType . Plain ) )
307
+ DataFormat . Json => request . AddJsonBody ( obj , contentType ?? ContentType . Json ) ,
308
+ DataFormat . Xml => request . AddXmlBody ( obj , contentType ?? ContentType . Xml ) ,
309
+ DataFormat . Binary => request . AddParameter ( new BodyParameter ( "" , obj , contentType ?? ContentType . Binary ) ) ,
310
+ _ => request . AddParameter ( new BodyParameter ( "" , obj . ToString ( ) ! , contentType ?? ContentType . Plain ) )
310
311
} ;
311
312
}
312
313
313
314
return
314
315
obj is string str ? request . AddParameter ( new BodyParameter ( "" , str , contentType ) ) :
316
+ obj is byte [ ] bytes ? request . AddParameter ( new BodyParameter ( "" , bytes , contentType ) ) :
315
317
contentType . Contains ( "xml" ) ? request . AddXmlBody ( obj , contentType ) :
316
318
contentType . Contains ( "json" ) ? request . AddJsonBody ( obj , contentType ) :
317
319
throw new ArgumentException ( "Non-string body found with unsupported content type" , nameof ( obj ) ) ;
0 commit comments