“操作已超时”;在C#中通过DocuSign api登录时出错 [英] "The operation has timed out" error when login via DocuSign api in C#

查看:81
本文介绍了“操作已超时”;在C#中通过DocuSign api登录时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自2018年5月31日以来,我在登录时从DocuSign API收到以下错误。


DocuSign.eSign.Client .ApiException:调用登录时出错:操作已超时。


自去年以来,我们一直在测试DocuSign API。所有这些都可以与我们内部的集成应用程序正常工作。昨天是我们第一次在登录时收到此错误消息,而问题仍然存在。如果我通过演示DocuSign网站


代码更改



请在代码中的红色框内进行以下更改。



快速修复





代码行

  ServicePointManager.SecurityProtocol = Sec urityProtocolType.Tls12; 

请使用System.Net确保存在在您的命名空间中。


I'm getting the following error since 31/05/2018 from the DocuSign API on login.

DocuSign.eSign.Client.ApiException: 'Error calling Login: The operation has timed out'.

We have been testing DocuSign API since last year and it was all working fine with our in-house integrated application. Yesterday was the first time we got this error message in login and the issue is there still. If I login via the demo DocuSign web site https://appdemo.docusign.com, I can log in. But if I try the same via DocuSign API it gives the timeout error.

Configuration.ApiClient.Configuration.ApiClient.RestClient.BaseUrl is set to https://demo.docusign.net/restapi/

new System.Collections.Generic.Mscorlib_DictionaryDebugView<string, string>(Configuration.DefaultHeader).Items[0] is set to {[X-DocuSign-Authentication, {"Username":[username], "Password":[password], "IntegratorKey":[IntegratorKey]}]}

We haven't changed the username or password or IntegratorKey at all.

The value of response.StatusCode is returned as 0. Please find my code for login below.

public ApiResponse< LoginInformation > LoginWithHttpInfo (AuthenticationApi.LoginOptions options = null)
    {            

        var path_ = "/v2/login_information";

        var pathParams = new Dictionary<String, String>();
        var queryParams = new Dictionary<String, String>();
        var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
        var formParams = new Dictionary<String, String>();
        var fileParams = new Dictionary<String, FileParameter>();
        Object postBody = null;

        // to determine the Content-Type header
        String[] httpContentTypes = new String[] {

        };
        String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

        // to determine the Accept header
        String[] httpHeaderAccepts = new String[] {
            "application/json"
        };
        String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
        if (httpHeaderAccept != null)
            headerParams.Add("Accept", httpHeaderAccept);

        // set "format" to json by default
        // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
        pathParams.Add("format", "json");


        if (options != null)
        {
            if (options.apiPassword != null) queryParams.Add("api_password", Configuration.ApiClient.ParameterToString(options.apiPassword)); // query parameter
            if (options.includeAccountIdGuid != null) queryParams.Add("include_account_id_guid", Configuration.ApiClient.ParameterToString(options.includeAccountIdGuid)); // query parameter
            if (options.loginSettings != null) queryParams.Add("login_settings", Configuration.ApiClient.ParameterToString(options.loginSettings)); // query parameter

        }


        // make the HTTP request
        IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, 
            Method.GET, queryParams, postBody, headerParams, formParams, fileParams,
            pathParams, httpContentType);

        int statusCode = (int) response.StatusCode;

        if (statusCode >= 400)
            throw new ApiException (statusCode, "Error calling Login: " + response.Content, response.Content);
        else if (statusCode == 0)
            throw new ApiException (statusCode, "Error calling Login: " + response.ErrorMessage, response.ErrorMessage);

        return new ApiResponse<LoginInformation>(statusCode,
            response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
            (LoginInformation) Configuration.ApiClient.Deserialize(response, typeof(LoginInformation)));

    }

解决方案

DocuSign Support Website

For more details please read the link

Code Change

Please do this following changes (in red box) in your code.

Quick Fix

Code Line

  ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Please ensure using System.Net; exists in your namespace.

这篇关于“操作已超时”;在C#中通过DocuSign api登录时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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