Docusign c#sdk错误调用getDocument和ListDocuments

时间:2018-03-10 19:22:45

标签: c# docusignapi

我正在尝试使用C#sdk从我的Docusign帐户中获取所有已签名的文档。 到目前为止,我可以登录,但是当我尝试检索文档列表或一个文档时,它总是向我DocuSign.eSign.Client.ApiException: 'Error calling ListDocuments: 'DocuSign.eSign.Client.ApiException: 'Error calling GetDocument: '提供404状态。

这是代码

    static void Main(String[] args)
    {
        string envelopeId = "my_envelop_id";
        string accountId = Init();

        EnvelopesApi envelopesApi = new EnvelopesApi();

        //Here is where the exception is thrown
        EnvelopeDocumentsResult docsList = envelopesApi.ListDocuments(accountId, envelopeId);

        // GetDocument() API call returns a MemoryStream
        //var docStream = envApi.GetDocument(accountId, envelopeId, "my_document_id");
    }

    public string Init()
    {
        // initialize client for desired environment (for production change to www)
        ApiClient apiClient = new ApiClient(_baseUri);
        Configuration.Default.ApiClient = apiClient;

        Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", _authHeader);

        // we will retrieve this from the login API call
        string accountId = null;

        // login call is available in the authentication api 
        AuthenticationApi authApi = new AuthenticationApi();
        LoginInformation loginInfo = authApi.Login();

        // parse the first account ID that is returned (user might belong to multiple accounts)
        accountId = loginInfo.LoginAccounts[0].AccountId;
        urlCAC = loginInfo.LoginAccounts[0].BaseUrl;

        // Update ApiClient with the new base url from login call
        apiClient = new ApiClient(loginInfo.LoginAccounts[0].BaseUrl);

        return accountId;
    }

任何帮助都会让我感到非常困难!提前致谢

更新

最后我开始工作了。问题出在apiClient = new ApiClient(loginInfo.LoginAccounts[0].BaseUrl);行。当我删除此行时一切正常。感谢所有回复。

1 个答案:

答案 0 :(得分:0)

问题与var envApi = new EnvelopesApi(urlCAC);

一致

将baseURL插入到EnvelopesAPI对象中是不正确的。您可以在Fiddler中看到这一点 - Visual Studio将尝试拨打GET https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/v2/accounts/{{accountId}}/envelopes/{{envelopeId}}/documents HTTP/1.1 - 包括/v2/accounts/{{accountID/}}两次