无法在异步中的httpresponsemessage中返回输出
我正在努力阅读Adapter.postasync调用的输出。我期望它在我的响应对象中的httpresponsemessage类型中。
当我更改 dim响应为任务对 dim响应作为任务(httpresponsemessage的任务)我会遇到错误,例如将隐式转换从任务转换为任务(OF)
这是代码i 具有到目前为止的调用方法
VB中
Dim response As Task =
adapter.PostAsync("api/rules",modelObject)
在c#适配器类中的
public Task PostAsync<TResult>(string end, TResult postObject)
{
// In this method I am calling api and returns output as Task<httpresponsemessage>
return httpClient.PostAsync(end, new stringcontent(jsonConvert.SerializeObject(postObject, json settings), encoding.UTF8, "application/json"));
}
I am struggling to read output from my adapter.PostAsync call. I am expecting it in a httpresponsemessage type in my response object.
When I change Dim response As Task to Dim response As Task(Of httpresponsemessage) I am getting error like disallows implicit conversion from task to task(of )
This is the code I have so far
Calling method which is in VB
Dim response As Task =
adapter.PostAsync("api/rules",modelObject)
Called method which is in c# adapter class
public Task PostAsync<TResult>(string end, TResult postObject)
{
// In this method I am calling api and returns output as Task<httpresponsemessage>
return httpClient.PostAsync(end, new stringcontent(jsonConvert.SerializeObject(postObject, json settings), encoding.UTF8, "application/json"));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论