简体   繁体   English

为什么 RestSharp RestClient ExecuteAsync<filecontentresult> 在根级别返回 *Data 无效。 1号线,position 1.*?</filecontentresult>

[英]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.

相关问题 错误加载XML文件{“根级别的数据无效。 第1行,位置1。”} - Error Loading XML File {“Data at the root level is invalid. Line 1, position 1.”} 根级别的数据无效。 第1行,第1位,同时读取xml - Data at the root level is invalid. Line 1, position 1. while reading xml XML反序列化:根级别的数据无效。 第1行的位置1。尝试了几乎所有内容 - XML deserialization: Data at the root level is invalid. Line 1 position 1. Tried almost everything C#XmlDocument.LoadXml(string)失败-根级别的数据无效。 第1行的位置1。 - C# XmlDocument.LoadXml(string) fail -data at the root level is invalid. line 1 position 1. xmldocument API 微软翻译异常:“根级别的数据无效。 第 1 行,position 1。” - API Microsoft Translator Exception: “The data at the root level is invalid. Line 1, position 1.” 根级别的数据无效。 第1行,位置1 - Data at the root level is invalid. Line 1, position 1 根级别的数据无效。 第1行,内存xml中有效的位置1 - Data at the root level is invalid. Line 1, position 1 on valid in memory xml “根级别的数据无效。第 1 行,position 1”解析 XML 时 - "Data at the root level is invalid. Line 1, position 1" When Parsing XML SolrNET-根级别的数据无效。 第1行,位置1 - SolrNET - Data at the root level is invalid. Line 1, position 1 根级别的数据无效。 第1行在XML中的位置1 - data at the root level is invalid. line 1 position 1 in XML
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM