Skip to content

Commit cebe45f

Browse files
author
childish-sambino
authored
fix: Remove char set from content headers for JSON payloads (#967)
1 parent bd69b1b commit cebe45f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/SendGrid/SendGridClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ public async Task<Response> RequestAsync(
227227
Content = requestBody == null ? null : new StringContent(requestBody, Encoding.UTF8, this.MediaType),
228228
};
229229

230+
// Drop the default UTF-8 content type charset for JSON payloads since some APIs may not accept it.
231+
if (request.Content != null && this.MediaType == DefaultMediaType)
232+
{
233+
request.Content.Headers.ContentType.CharSet = null;
234+
}
235+
230236
// set header overrides
231237
if (this.options.RequestHeaders?.Count > 0)
232238
{

0 commit comments

Comments
 (0)