kranthi pothireddy
kranthi pothireddy

Reputation: 51

Error calling CreateEnvelope

Am doing POC using DocuSign third party. Am facing some issues, while creating or sending envelope, am getting error message

Error calling CreateEnvelope: { "errorCode": "PARTNER_AUTHENTICATION_FAILED", "message": "The specified Integrator Key was not found or is disabled. An Integrator key was not specified." }

Am able to authenticate below code, for security reason's am not putting my email id or password.

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;
}

In the code code am getting accountid after authentication.

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 = "[email protected]";
            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; 
        }
    }
}

In the above code am getting exception as i mentioned. Could you please help me out on this.

Upvotes: 0

Views: 633

Answers (1)

Wax_Lee
Wax_Lee

Reputation: 13

Are you calling your DocLogin method immediately before calling CreateSendEnvelope? I suspect your login is expiring before you get around to creating the envelope. Try calling the login method from CreateSendEnvelope and see what happens then.

Upvotes: 1

Related Questions