[英]Why is RestSharp RestClient ExecuteAsync<FileContentResult> returning *Data at the root level is invalid. Line 1, position 1.*?
I'm calling a microservice API using RestSharp with a POST message in a RestClient ExecuteAsync call for testing purposes.我在 RestClient ExecuteAsync 调用中使用 RestSharp 和 POST 消息调用微服务 API 以进行测试。 The data is coming back null and an error message is being returned as Data at the root level is invalid.
数据返回 null 并返回一条错误消息,因为根级别的数据无效。 Line 1, position 1.
1号线,position 1.
The call works otherwise in the normal course of using the API in our application.在我们的应用程序中使用 API 的正常过程中,调用会以其他方式工作。 The API returns a FileContentResult.
API 返回一个 FileContentResult。 I see information in the Content.
我在内容中看到信息。
public static async Task<IRestResponse<FileContentResult>> ExecuteAsyncFileRequests(this RestClient client, IRestRequest request)
{
var response = await client.ExecuteAsync<FileContentResult>(request);
return response;
}
Your server probably returns some error as HTML, and deserialization of the response fails for that reason.您的服务器可能会返回一些错误 HTML,因此响应的反序列化失败。 It's easy to check by calling
打电话查询很方便
var response = await client.ExecuteAsync(request);
and inspecting the response.Content
property.并检查
response.Content
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.