private static async Task <string> FormatContentStringAsync(HttpPipelineRequestContent requestContent, Encoding encoding, CancellationToken cancellationToken) { using (var memoryStream = new MemoryStream()) { await requestContent.WriteToAsync(memoryStream, cancellation : cancellationToken).ConfigureAwait(false); return(encoding.GetString(FormatContent(memoryStream.ToArray()))); } }