当我尝试从StreamReader
读取响应时,出现此错误。
以下是代码部分receiptimageresult = rd.ReadToEnd()
,这是我的错误。
var jsonDeliveryData2 = JsonConvert.SerializeObject(Deliverydata2);
using (HttpClientHandler ClientHandler = new HttpClientHandler())
using (HttpClient Client = new HttpClient(ClientHandler))
{
Client.Timeout = TimeSpan.FromSeconds(120); Client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
var content = new StringContent(jsonDeliveryData2, Encoding.UTF8, "application/json");
var resultN = await Client.PostAsync(uri5, content);
var enc = Encoding.UTF8;
using (Stream responseStream = resultN.Content.ReadAsStreamAsync().Result)
{
using (var decompressedStream = new GZipStream(responseStream, CompressionMode.Decompress))
{
using (var rd = new StreamReader(decompressedStream, enc))
{
receiptimageresult = rd.ReadToEnd(); ` here i am getting error`
}
}
}
}
堆栈跟踪:-
Message: Corrupted data ReadInternal
InnerMessage:
StackTrace: at System.IO.Compression.DeflateStreamNative.CheckResult (System.Int32 result, System.String where) [0x00082] in /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/mcs/class/System/System.IO.Compression/DeflateStream.cs:499
at System.IO.Compression.DeflateStreamNative.ReadZStream (System.IntPtr buffer, System.Int32 length) [0x0000d] in /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/mcs/class/System/System.IO.Compression/DeflateStream.cs:401
at System.IO.Compression.DeflateStream.ReadInternal (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x00027] in /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/mcs/class/System/System.IO.Compression/DeflateStream.cs:131
at System.IO.Compression.DeflateStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x00071] in /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/mcs/class/System/System.IO.Compression/DeflateStream.cs:161
at System.IO.Compression.GZipStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x00006] in /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/external/corefx/src/System.IO.Compression/src/System/IO/Compression/GZipStream.cs:84
at System.IO.StreamReader.ReadBuffer () [0x00028] in /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/io/streamreader.cs:586
at System.IO.StreamReader.ReadToEnd () [0x00052] in /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/io/streamreader.cs:451
at ATSS.UpdatoToServer+<UpdatoToLiveServer>d__0.MoveNext () [0x044e0]
您能告诉我我在代码中做错了什么吗?