如何调试 FreshDeck API 调用

问题描述

在我的代码中:

        public static CompanyResponse GetCompanyInfo(string companyId)
        {
            Logger.Info(LogUtility.MethodCalled);

            Logger.Debug(string.Format("Getting company information with company ID {0}",companyId));

            var httpWebRequest = ConfigureHttpRequest(Globals.COMPANY_TYPE,"GET",companyId);

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var responseJson = streamReader.ReadToEnd();

                // Parse the string as JSON and use the data to fill the CompanyResponse object
                var response = Newtonsoft.Json.JsonConvert.DeserializeObject<CompanyResponse>(responseJson);

                return response;
            }
        }

当部署为后端 API 调用时,代码似乎在调用中停止。

检查我设置的调试语句时:

2021/02/07 00:34:51.608 DEBUG   DOECaspioFreshdesk.CaspioConfig+<Register>d__8 [MoveNext] - Access token successfully generated.
2021/02/07 00:34:51.639 DEBUG   DOECaspioFreshdesk.Controllers.FreshdeskController+<UpdateTicketInfo>d__2 [MoveNext] - Method called.
2021/02/07 00:34:51.655 INFO    DOECaspioFreshdesk.Services.FreshdeskService [GetTicketInfo] - [NoIdentity] Method called.
2021/02/07 00:34:51.655 DEBUG   DOECaspioFreshdesk.Services.FreshdeskService [GetTicketInfo] - Getting information for ticket 372
2021/02/07 00:34:52.014 INFO    DOECaspioFreshdesk.Services.FreshdeskService [GetCompanyInfo] - [NoIdentity] Method called.
2021/02/07 00:34:52.014 DEBUG   DOECaspioFreshdesk.Services.FreshdeskService [GetCompanyInfo] - Getting company information with company ID 66000250186

作为 C# 的新手,我想知道这个函数是否有任何明显的结构问题。我将使用额外的调试功能更新当前线程,以检查它在哪里卡住了。

在每个部分添加新的调试语句:

        public static CompanyResponse GetCompanyInfo(string companyId)
        {
            Logger.Info(LogUtility.MethodCalled);

            Logger.Debug(string.Format("GetCompanyInfo: Getting company information with company ID {0}",companyId);

            Logger.Info(LogUtility.MethodCalled);

            Logger.Debug(string.Format("GetCompanyInfo: GET {0} completed",companyId));

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            Logger.Info(LogUtility.MethodCalled);

            Logger.Debug(string.Format("GetCompanyInfo: GET {0} httpGetResponse completed",companyId));

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                Logger.Info(LogUtility.MethodCalled);

                Logger.Debug(string.Format("GetCompanyInfo: Entered StreamReader"));

                var responseJson = streamReader.ReadToEnd();

                Logger.Info(LogUtility.MethodCalled);

                Logger.Debug(string.Format("GetCompanyInfo: streamReader completed"));

                // Parse the string as JSON and use the data to fill the CompanyResponse object
                var response = Newtonsoft.Json.JsonConvert.DeserializeObject<CompanyResponse>(responseJson);

                Logger.Info(LogUtility.MethodCalled);

                Logger.Debug(string.Format("GetCompanyInfo: filled in CompanyResponse object"));

                return response;
            }
        }

新的输出是:

2021/02/07 00:48:04.440 INFO    DOECaspioFreshdesk.WebApiApplication [Application_Start] - Application was initiated.
2021/02/07 00:48:05.705 INFO    DOECaspioFreshdesk.WebApiConfig [Register] - [NoIdentity] Method called.
2021/02/07 00:48:05.721 DEBUG   DOECaspioFreshdesk.CaspioConfig+<Register>d__8 [MoveNext] - [NoIdentity] Method called.
2021/02/07 00:48:05.736 DEBUG   DOECaspioFreshdesk.Services.CaspioRESTAPIService+<GetAccesstoken>d__2 [MoveNext] - Method called
2021/02/07 00:48:05.736 DEBUG   DOECaspioFreshdesk.CaspioConfig+<LoadConfigs>d__7 [MoveNext] - Method called.
2021/02/07 00:48:06.143 DEBUG   DOECaspioFreshdesk.CaspioConfig+<Register>d__8 [MoveNext] - Access token successfully generated.
2021/02/07 00:48:06.174 DEBUG   DOECaspioFreshdesk.Controllers.FreshdeskController+<UpdateTicketInfo>d__2 [MoveNext] - Method called.
2021/02/07 00:48:06.174 INFO    DOECaspioFreshdesk.Services.FreshdeskService [GetTicketInfo] - [NoIdentity] Method called.
2021/02/07 00:48:06.174 DEBUG   DOECaspioFreshdesk.Services.FreshdeskService [GetTicketInfo] - Getting information for ticket 373
2021/02/07 00:48:06.533 INFO    DOECaspioFreshdesk.Services.FreshdeskService [GetCompanyInfo] - [NoIdentity] Method called.
2021/02/07 00:48:06.533 DEBUG   DOECaspioFreshdesk.Services.FreshdeskService [GetCompanyInfo] - GetCompanyInfo: Getting company information with company ID 66000250186

它似乎在实例化 httpWebRequest 之后立即停止。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...