我遇到了Restsharp的问题,其中响应无效。问题似乎只在返回的数据量很大时才会出现。
我使用以下代码从RestSharp获取响应。因为我知道实际的http响应是正常的(通过使用Fiddler)我有点卡在这里发生的事情。响应是否太大了?它返回450个结果,每个结果有4个值。
var response = client.Execute(request);
var content = response.Content;
前两个括号是正确的。返回的每个对象应该有4个值,但在某些时候它只会中断。
"Id": 2143893
}, {
"Country": null,
"CrmId": "29084241146",
"Name": "Sara Johnsen1",
"Id": 2143894
}, {
"Country": null,
"CrmId": "19065337870",
"Name": "Sara Andersen68",
"Id": 2143895
}, {
"Country": null,
"CrmId": "08019044271",
"Name": "test",
"Id"...489 ","
Name ":"
Magnus Jensen102 ","
Id ":2143927},{"
Country ":null,"
CrmId ":"
11053848682 ","
这应该是这样的:
},
{
"Country":null,
"CrmId":"04075544842",
"Name": "Sara Andersen68",
"Id":2146236
},
{
"Country":null,
"CrmId":"29114839645",
"Name": "Magnus Andersen21",
"Id":2146237
},
{
"Country":null,
"CrmId":"27045633905",
"Name": "Tom Kato21",
"Id":2146238
},
{
"Country":null,
"CrmId":"16045532686",
"Name": "Ole Jensen94",
"Id":2146239
}
我使用JsonLint检查导致以下错误的结果:
Error: Parse error on line 1056:
...e": "test", "Id"...489 "," Name
----------------------^
Expecting 'EOF', '}', ':', ',', ']', got 'undefined'
当使用Fiddler检查Web服务返回的实际结果时,结果是完美的,因此它在RestSharp中的某处发生错误。