始终将文档添加到 docusign 信封 return false
Adding document to docusign envelope always return false
我正在使用以下代码尝试使用 c# API 的 AddDocument 函数将 pdf 文档添加到包含多个文档的现有模板,但结果总是错误的。模板发送成功,所有预设文件发送正确。如何正确添加pdf文档?我必须使用代码添加 pdf 文档,因为每次我们发送模板时这个特定文档都是不同的。我已经测试了 GetIPS 函数,它返回了 pdf 文档的 byte[],所以我知道这不是问题所在。
这是我的代码
byte[] ips = GetIPS("");
RestSettings.Instance.DocuSignAddress = "https://demo.docusign.net";
RestSettings.Instance.WebServiceUrl = RestSettings.Instance.DocuSignAddress + "/restapi/v2";
RestSettings.Instance.IntegratorKey = integratorKey;
DocuSign.Integrations.Client.Account account = new DocuSign.Integrations.Client.Account();
account.Email = username;
account.Password = password;
var loginResult = account.Login();
Template template = new Template();
template.TemplateId = templateId;
template.Login = account;
template.EmailSubject = emailSubject;
template.EmailBlurb = emailMessage;
var documents = template.GetDocuments();
TemplateRole tr = new TemplateRole();
var roles = new List<TemplateRole>();
//Handle Primary Client
roles.Add(new TemplateRole
{
roleName = "Primary Client",
name = primaryClientName,
email = primaryClientEmail,
tabs = new RoleTabs
{
textTabs = new RoleTextTab[] {
new RoleTextTab {
tabLabel = "FeeEffectiveDate",
value = effectiveDate
},
new RoleTextTab {
tabLabel = "FeePercentage",
value = fee
}
}
},
});
if (secondaryClientName.Trim().Length != 0)
{
roles.Add(new TemplateRole
{
roleName = "Secondary Client",
name = secondaryClientName,
email = secondaryClientEmail,
});
}
roles.Add(new TemplateRole
{
roleName = "President",
name = presidentName,
email = presidentEmail,
});
roles.Add(new TemplateRole
{
roleName = "Css",
name = cssName,
email = cssEmail,
});
template.TemplateRoles = roles.ToArray<TemplateRole>();
template.Status = "sent";
//The following code always return false
bool status = template.AddDocument(ips, "IPS.pdf", 1);
var result = template.Create();
为了使用 AddDocument
功能,信封必须处于草稿状态(您也可以在 source code 中对此功能的备注中看到)。因此,在您的情况下,您必须首先创建草稿信封(通过将信封状态更改为 "created"),然后调用 AddDocument
函数,最后将信封状态更新为 "sent" 以发送信封。
例如:
.
.
.
template.Status = "created";
var result = template.Create();
bool status = template.AddDocument(ips, "IPS.pdf", 2);
template.Status = "sent";
result = template.UpdateStatus();
请注意,文档索引是文档 ID,必须与模板中现有文档的 ID 不同。否则,具有相同 ID 号的现有文档将被新文档替换。
我正在使用以下代码尝试使用 c# API 的 AddDocument 函数将 pdf 文档添加到包含多个文档的现有模板,但结果总是错误的。模板发送成功,所有预设文件发送正确。如何正确添加pdf文档?我必须使用代码添加 pdf 文档,因为每次我们发送模板时这个特定文档都是不同的。我已经测试了 GetIPS 函数,它返回了 pdf 文档的 byte[],所以我知道这不是问题所在。
这是我的代码
byte[] ips = GetIPS("");
RestSettings.Instance.DocuSignAddress = "https://demo.docusign.net";
RestSettings.Instance.WebServiceUrl = RestSettings.Instance.DocuSignAddress + "/restapi/v2";
RestSettings.Instance.IntegratorKey = integratorKey;
DocuSign.Integrations.Client.Account account = new DocuSign.Integrations.Client.Account();
account.Email = username;
account.Password = password;
var loginResult = account.Login();
Template template = new Template();
template.TemplateId = templateId;
template.Login = account;
template.EmailSubject = emailSubject;
template.EmailBlurb = emailMessage;
var documents = template.GetDocuments();
TemplateRole tr = new TemplateRole();
var roles = new List<TemplateRole>();
//Handle Primary Client
roles.Add(new TemplateRole
{
roleName = "Primary Client",
name = primaryClientName,
email = primaryClientEmail,
tabs = new RoleTabs
{
textTabs = new RoleTextTab[] {
new RoleTextTab {
tabLabel = "FeeEffectiveDate",
value = effectiveDate
},
new RoleTextTab {
tabLabel = "FeePercentage",
value = fee
}
}
},
});
if (secondaryClientName.Trim().Length != 0)
{
roles.Add(new TemplateRole
{
roleName = "Secondary Client",
name = secondaryClientName,
email = secondaryClientEmail,
});
}
roles.Add(new TemplateRole
{
roleName = "President",
name = presidentName,
email = presidentEmail,
});
roles.Add(new TemplateRole
{
roleName = "Css",
name = cssName,
email = cssEmail,
});
template.TemplateRoles = roles.ToArray<TemplateRole>();
template.Status = "sent";
//The following code always return false
bool status = template.AddDocument(ips, "IPS.pdf", 1);
var result = template.Create();
为了使用 AddDocument
功能,信封必须处于草稿状态(您也可以在 source code 中对此功能的备注中看到)。因此,在您的情况下,您必须首先创建草稿信封(通过将信封状态更改为 "created"),然后调用 AddDocument
函数,最后将信封状态更新为 "sent" 以发送信封。
例如:
.
.
.
template.Status = "created";
var result = template.Create();
bool status = template.AddDocument(ips, "IPS.pdf", 2);
template.Status = "sent";
result = template.UpdateStatus();
请注意,文档索引是文档 ID,必须与模板中现有文档的 ID 不同。否则,具有相同 ID 号的现有文档将被新文档替换。