流读/写超时导致无效的操作异常 [英] Stream Read/Write Timeout causes Invalid Operation Exception

查看:278
本文介绍了流读/写超时导致无效的操作异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  RestClient client = new RestClient(https:// gds.eligibleapi.com/v1.5/coverage/all?api_key=
+ apiSecret +& payer_id =+ payerID +& service_provider_organization_name =+
providerOrgName +& provider_npi =+ NPI +& member_id =+ ptPolicyID +
& member_first_name =+ ptFirstName +& member_last_name =+ ptLastName
+& member_dob =+ ptDOB +& ; date =+ DOS +& service_type =+ serviceType +
& format = x12);

var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
string response271 = response.Content;
Stream response271Stream = StringStream.GenerateStreamFromString(response271);
pre>

我一直在线上发现错误:

  Stream response271Stream = StringStream.GenerateStreamFromString(response271)





'response271Stream.ReadTimeout'抛出一个System.InvalidOperationException异常'

这里是一个图片供参考:



这只是我想用于这个API的几个调用之一。任何人都可以帮我找出为什么它失败了我的请求流API响应?感谢!

解决方案

对于任何来到这个页面的人来说,这个问题是一个意外的null变量,如果没有回应,请求就会超时。我的修复是首先尝试允许我的客户端超时。一旦到位,我就可以把问题缩小到数据本身,这是我的问题。



这个答案很快就会回来,但是我会尽力回答任何人在未来可能会有关于我的答案的问题。


I am trying to get a request from an API using:

RestClient client = new RestClient("https://gds.eligibleapi.com/v1.5/coverage/all?api_key="
    + apiSecret + "&payer_id=" + payerID + "&service_provider_organization_name=" + 
    providerOrgName + "&provider_npi=" + NPI + "&member_id=" + ptPolicyID + 
    "&member_first_name=" + ptFirstName + "&member_last_name=" + ptLastName 
    + "&member_dob=" + ptDOB + &date=" + DOS + "&service_type=" + serviceType +
    "&format=x12");

var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
string response271 = response.Content;
Stream response271Stream = StringStream.GenerateStreamFromString(response271);

I keep getting the error on the Line:

Stream response271Stream = StringStream.GenerateStreamFromString(response271)

That says:

'response271Stream.ReadTimeout' threw an exception of type System.InvalidOperationException'

And here is a picture for reference:

This is just one of a few calls I want to use with this API. Can anyone help me figure out why it failed upon my request to Stream the API's response? Thanks!

解决方案

For anyone who comes to this page, The issue was an unexpected null variable which went unhandled in the API. Without a response, the request was timing out. My fix was to first, try to allow for timeouts with my client. Once in place, I was able to narrow down issue to the data itself and there was my problem.

This answer is coming back very late, but I will try to get to questions anyone might have regarding my answer in the future.

这篇关于流读/写超时导致无效的操作异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆