Skip to content

Commit a7d2662

Browse files
committed
Fix the AddBody issue with byte[] value #1761
1 parent 747befe commit a7d2662

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/RestSharp/Request/RestRequestExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public static RestRequest AddBody(this RestRequest request, object obj, string?
313313

314314
return
315315
obj is string str ? request.AddParameter(new BodyParameter("", str, contentType)) :
316-
obj is byte[] bytes ? request.AddParameter(new BodyParameter("", bytes, contentType)) :
316+
obj is byte[] bytes ? request.AddParameter(new BodyParameter("", bytes, contentType, DataFormat.Binary)) :
317317
contentType.Contains("xml") ? request.AddXmlBody(obj, contentType) :
318318
contentType.Contains("json") ? request.AddJsonBody(obj, contentType) :
319319
throw new ArgumentException("Non-string body found with unsupported content type", nameof(obj));

0 commit comments

Comments
 (0)