json WEB API GET调用导致代码移动到主机时找不到文件

rqdpfwrv  于 2023-02-10  发布在  其他
关注(0)|答案(1)|浏览(74)

The bounty expires in 7 days. Answers to this question are eligible for a +50 reputation bounty. James Waters is looking for a canonical answer: Really stuck here any suggestions would be appreciated. :)

Here is the error, works fine via VS locally but I get this error once I move it to the TEST server. I would assume its some server setting that isn't allowing the process access but if there is a work around anyone knows, I would appreciate it. I'm hitting a json GET api

An error has occurred via the CCR Referrals application. See the exception details below for further explanation.

User: James Waters
System.Net.WebException: Could not find file 'c:\windows\system32\inetsrv\mxy=445544'. ---> System.Net.WebException: Could not find file 'c:\windows\system32\inetsrv\mxy=445544'. ---> System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\mxy=445544'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.Net.FileWebStream..ctor(FileWebRequest request, String path, FileMode mode, FileAccess access, FileShare sharing, Int32 length, Boolean async) at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint) --- End of inner exception stack trace --- at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint) at System.Net.FileWebRequest.GetResponseCallback(Object state) --- End of inner exception stack trace --- at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest&
string API_URL = (string)System.Configuration.ConfigurationManager.AppSettings["API_URL"]; string username = "TheDudeAbides"; string password = "xyz1234"; string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password));

//THE COMPLETED API URL plus the rn to lookup
            API_URL = API_URL + "rn="+rn;

            try
            {
                //get th json results from the response from the URL call
                using (WebClient client2 = new WebClient())
                {

                    //tell the call to use basic authorization and add the credentials to the client call
                    client2.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
                   var responseOK = client2.DownloadString(PRES_API_URL);
                   List<Protocol> listProts = Service.GetOpenProtsAppTable();

                    if (responseOK != null)
                    {
                            if (responseOK != "")
                            {  
                                JArray jsonArray = JArray.Parse(responseOK);
                                foreach(JObject item in jsonArray)
                                {

                                      enrollment pe = new Patient_Enrollment();                                 
                                      //Find the protocol ID from the jSON response
                                      var itemProperties = item.Children<JProperty>();
                                      var protocolElement = itemProperties.FirstOrDefault(x => x.Name == "protocol");
                                      var protocol = protocolElement.Value; 
                                
                                    Protocol prot = listProts.FirstOrDefault(i => i.protocolId_Display == protocol.ToString());
                                    if (prot != null)
                                    {
                                        pe.IprotocolId = prot.protocolId.ToString().Replace("-", "");
                                        pe.IshortTitle = prot.shortTitle;
                                        pe.IstudyId = Convert.ToString(prot.studyId);

                                        //instatiate the PRES API information into Patient_Enrollment objects, to compare to what Referrals has for enrollment on the MRN.
                                        enrollments.Add(pe);
                                    }                              

                                }

                            }
                    }
                }
            }
            catch (WebException e)
            {
                //email that the API is down.
                Email.SendErrorNotification("API Down", e.ToString());
            }

    }
bvjxkvbb

bvjxkvbb1#

抱歉,积分不足,无法评论...
在我看来,您配置了一个API_URL,但在调用客户端时使用了PRES_API_URL。这是问题所在吗?

相关问题