使用DocuSign第三方进行POC。我在面对一些问题时,在创建或发送信封时,收到错误消息
调用CreateEnvelope时出错:{ “errorCode”:“PARTNER_AUTHENTICATION_FAILED”, “message”:“未找到或已禁用指定的Integrator密钥。未指定Integrator密钥。” }
我可以对以下代码进行身份验证,但出于安全原因,我没有提供我的电子邮件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;
}
在代码中,我在认证后获得了认可。
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;
}
}
}
在上面的代码中我正如我所提到的那样得到异常。你能帮我解决这个问题。
答案 0 :(得分:1)
您在调用CreateSendEnvelope之前是否立即调用了DocLogin方法?在您开始创建信封之前,我怀疑您的登录信息已到期。尝试从CreateSendEnvelope调用login方法,然后看看会发生什么。