调用CreateEnvelope出错

本文关键字:出错 CreateEnvelope 调用 | 更新日期: 2023-09-27 17:54:20

我使用DocuSign第三方进行POC。我面临一些问题,在创建或发送信封时,我得到错误消息

调用CreateEnvelope:{出错"错误代码":"PARTNER_AUTHENTICATION_FAILED","message": "指定的集成密钥未找到或被禁用。"未指定集成商密钥。"}

我可以验证下面的代码,出于安全原因,我没有把我的电子邮件id或密码。

private string DocLogin()
{
    string accountId = null;
    try
    {
        ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
        Configuration cfi = new Configuration(apiClient);
        string authHeader = "{'"Username'":'"" + username + "'", '"Password'":'"" + password + "'", '"IntegratorKey'":'"" + integratorKey + "'"}";
        cfi.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
        AuthenticationApi authApi = new AuthenticationApi(cfi);
        LoginInformation loginInfo = authApi.Login();
        accountId = loginInfo.LoginAccounts[0].AccountId;
    }
    catch (Exception ex)
    {
        string inner = ex.Message;
    }
    return accountId;
}

在代码代码中,验证后得到accountid。

private void CreateSendEnvelope(string accountID)
{
    string pdfPath = Server.MapPath("~/PDF/pdf-sample.pdf");
    if (!string.IsNullOrEmpty(accountID))
    {
        if (System.IO.File.Exists(pdfPath))
        {
            byte[] fileBytes = System.IO.File.ReadAllBytes(pdfPath);
            EnvelopeDefinition envDef = new EnvelopeDefinition();
            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";
            Document doc = new Document();
            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name = "img003.pdf";
            doc.DocumentId = "1";
            envDef.Documents = new List<Document>();
            envDef.Documents.Add(doc);
            Signer signer = new Signer();
            signer.Email = "Test@gmail.com";
            signer.Name = "Test";
            signer.RecipientId = "1";
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List<SignHere>();
            SignHere signHere = new SignHere();
            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.RecipientId = "1";
            signHere.XPosition = "100";
            signHere.YPosition = "100";
            signer.Tabs.SignHereTabs.Add(signHere);
            envDef.Recipients = new Recipients();
            envDef.Recipients.Signers = new List<Signer>();
            envDef.Recipients.Signers.Add(signer);
            // set envelope status to "sent" to immediately send the signature request 
            envDef.Status = "sent";
            //envDef.Status = "created";
            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests) 
            EnvelopesApi envelopesApi = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountID, envDef);
            // print the JSON response 
            Console.WriteLine("EnvelopeSummary:'n{0}", JsonConvert.SerializeObject(envelopeSummary));
            //APIServiceSoapClient apiService = new APIServiceSoapClient();
            //return envelopeSummary; 
        }
    }
}

在上面的代码我得到异常,因为我提到。你能帮我一下吗?

调用CreateEnvelope出错

您是否在调用CreateSendEnvelope之前立即调用您的DocLogin方法?我怀疑您的登录在创建信封之前就过期了。尝试从CreateSendEnvelope调用login方法,看看会发生什么。