提问人:Ramesh Baddam 提问时间:11/17/2023 更新时间:11/17/2023 访问量:17
内存流在通过 HttpPost 发布时为空
Memory stream is empty when it posted throuh HttpPost
问:
我从 BuildPackage 方法获取内存流,并通过 D365 Enqueue api (UploadBinaryAsync) 发送此流。 不知何故,当我在本地测试时,我可以在 D365 中看到数据,但是当我在 azure 中部署代码时,我看到的是空流。我错过了什么吗?
public async Task SendPackage(Entities Entities)
{
尝试 { var stream = await _packageBuilderProvider.BuildPackage(实体);
var bearerToken = await _authorizationProvider.GenerateBearerTokenAsync();
stream.Position=0;
var response = await _httpCustomClientProvider.UploadBinaryAsync(_vendorPaymentsEnqueueUrl, stream, bearerToken);
var res = response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
}
catch (Exception ex)
{
_logger.LogError($"VendorPaymentsProvider-Something went wrong while sending the vendor payment data package. Please exception details:{ex}");
// throw;
}
}
UploadBinaryAsync 的代码
public async Task UploadBinaryAsync(string? path, Stream stream, string bearerToken) { 尝试 {
StreamContent content = new(stream);
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
content.Headers.ContentLength = stream.Length;
return await this.PostAsync(path!, content, bearerToken);
}
catch (Exception ex)
{
throw;
}
}
答: 暂无答案
评论