DocuSign C# SDK 设置预填字段
DocuSign C# SDK setting prefilled fields
我试图在发送电子邮件之前设置预填字段,但它似乎不起作用。我有两个带有数据标签 fee
和 otherFee
.
的文本字段
尝试发送时,程序抛出以下错误:
{"errorCode":"REQUIRED_TAB_INCOMPLETE","message":"A Required field is incomplete. TabId: 0dfdf411-cafa-441e-b6e4-ef617e12de92"}
TabId
此处随每次调用而变化。我知道它必须与我的预填字段相关联,因为当我删除它们或删除 Mandatory
属性时,通过网站上的模板工具可以毫无问题地发送电子邮件。不确定为什么我得到这个唯一标识符而不是它们实际设置的数据标签。
我的代码:
//prepare client
var apiClient = new ApiClient(basePath);
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
var envelopesApi = new EnvelopesApi(apiClient);
//Make the envelope
TemplateRole signer1 = new TemplateRole
{
Email = signerEmail,
Name = signerName,
RoleName = "merchant",
};
EnvelopeDefinition envelope = new EnvelopeDefinition
{
TemplateId = templateId,
TemplateRoles = new List<TemplateRole> { signer1 },
Status = "created"
};
EnvelopeSummary result = envelopesApi.CreateEnvelope(accountId, envelope);
//set fields
Text fee = new Text {TabLabel = "fee", Value = "[=10=].50"};
Text otherFee = new Text {TabLabel = "otherFee", Value = ".77"};
PrefillTabs prefillTabs = new PrefillTabs {TextTabs = new List<Text> {fee, otherFee}};
Tabs tabs = new Tabs {PrefillTabs = prefillTabs};
var res = envelopesApi.CreateDocumentTabs(accountId, result.EnvelopeId, "1", tabs);
//update and send
Envelope envInfo = new Envelope();
envInfo.Status = "sent";
envelopesApi.Update(accountId, result.EnvelopeId, envInfo);
非常感谢任何帮助,这让我发疯了。
您可以使用预填充标签,这里是 live example。
您的问题 是您试图为模板设置 pre-fill 选项卡。那是不支持的。相反,使用常规选项卡并将它们标记为只读。 API Request Builder 有许多模板代码示例,您可以现场试用。
如上所述,您不能为服务器模板中的文档设置预填充选项卡。参见 templates post
预填充标签更适合使用 DocuSign 网络应用程序 发送 信封(交易)的人。您的 API 集成应用程序可以在 read-only 模式下使用常规选项卡。
这里是 JSON 和来自 API Request Builder 的预填充选项卡的 C# 示例。
"envelopeDefinition": {
"emailSubject": "Please sign the attached document",
"status": "sent",
"documents": [
{
"filename": "anchorfields.pdf",
"name": "Example document",
"fileExtension": "pdf",
"documentId": "1",
"tabs": {
"prefillTabs": {
"textTabs": [
{
"anchorString": "/field1/ ",
"bold": "true",
"font": "Garamond",
"fontColor": "BrightBlue",
"fontSize": "Size14",
"value": "This field and the following are all \"prefill\" fields: "
},
{
"anchorString": "/field1/ ",
"anchorXOffset": "0",
"anchorYOffset": "30",
"bold": "true",
"font": "Garamond",
"fontColor": "Black",
"fontSize": "Size12",
"value": "Checkbox:"
},
{
"anchorString": "/field1/ ",
"anchorXOffset": "90",
"anchorYOffset": "30",
"bold": "true",
"font": "Garamond",
"fontColor": "Black",
"fontSize": "Size12",
"value": "Radio button:"
},
{
"anchorString": "/field1/ ",
"anchorXOffset": "0",
"anchorYOffset": "60",
"bold": "true",
"font": "Garamond",
"fontColor": "Black",
"fontSize": "Size12",
"value": "Sender name:"
},
{
"anchorString": "/field1/ ",
"anchorXOffset": "190",
"anchorYOffset": "60",
"bold": "true",
"font": "Garamond",
"fontColor": "Black",
"fontSize": "Size12",
"value": "Sender company:"
}
],
"checkboxTabs": [
{
"anchorString": "/field1/ ",
"anchorXOffset": "70",
"anchorYOffset": "30",
"fontSize": "Size14",
"selected": "true"
}
],
"radioGroupTabs": [
{
"radios": [
{
"anchorString": "/field1/",
"anchorXOffset": "185",
"anchorYOffset": "30",
"selected": "true",
"fontSize": "Size14"
}
]
}
],
"senderNameTabs": [
{
"anchorString": "/field1/ ",
"anchorXOffset": "90",
"anchorYOffset": "58",
"font": "Garamond",
"fontColor": "DarkGreen",
"fontSize": "Size12"
}
],
"senderCompanyTabs": [
{
"anchorString": "/field1/ ",
"anchorXOffset": "310",
"anchorYOffset": "58",
"font": "Garamond",
"fontColor": "DarkGreen",
"fontSize": "Size12"
}
]
}
}
}
],
"recipients": {
"signers": [
{
"email": "signer_email@example.com",
"name": "Signer's name",
"recipientId": "1",
"clientUserId": "1000",
"tabs": {
"signHereTabs": [
{
"anchorString": "/sig1/",
"anchorXOffset": "20",
"anchorUnits": "pixels"
}
]
}
}
]
}
}
C#
static string SendDocuSignEnvelope()
{
SignHere signHereTab1 = new SignHere
{
AnchorString = "/sig1/",
AnchorUnits = "pixels",
AnchorXOffset = "20"
};
List<SignHere> signHereTabs1 = new List<SignHere> {signHereTab1};
Tabs tabs1 = new Tabs
{
SignHereTabs = signHereTabs1
};
Signer signer1 = new Signer
{
ClientUserId = "1000",
Email = "signer_email@example.com",
Name = "Signer's name",
RecipientId = "1",
Tabs = tabs1
};
List<Signer> signers1 = new List<Signer> {signer1};
Recipients recipients1 = new Recipients
{
Signers = signers1
};
Text textTab1 = new Text
{
AnchorString = "/field1/ ",
Bold = "true",
Font = "Garamond",
FontColor = "BrightBlue",
FontSize = "Size14",
Value = "This field and the following are all ""prefill"" fields: "
};
Text textTab2 = new Text
{
AnchorString = "/field1/ ",
AnchorXOffset = "0",
AnchorYOffset = "30",
Bold = "true",
Font = "Garamond",
FontColor = "Black",
FontSize = "Size12",
Value = "Checkbox:"
};
Text textTab3 = new Text
{
AnchorString = "/field1/ ",
AnchorXOffset = "90",
AnchorYOffset = "30",
Bold = "true",
Font = "Garamond",
FontColor = "Black",
FontSize = "Size12",
Value = "Radio button:"
};
Text textTab4 = new Text
{
AnchorString = "/field1/ ",
AnchorXOffset = "0",
AnchorYOffset = "60",
Bold = "true",
Font = "Garamond",
FontColor = "Black",
FontSize = "Size12",
Value = "Sender name:"
};
Text textTab5 = new Text
{
AnchorString = "/field1/ ",
AnchorXOffset = "190",
AnchorYOffset = "60",
Bold = "true",
Font = "Garamond",
FontColor = "Black",
FontSize = "Size12",
Value = "Sender company:"
};
List<Text> textTabs1 = new List<Text> {textTab1, textTab2, textTab3, textTab4, textTab5};
Checkbox checkboxTab1 = new Checkbox
{
AnchorString = "/field1/ ",
AnchorXOffset = "70",
AnchorYOffset = "30",
FontSize = "Size14",
Selected = "true"
};
List<Checkbox> checkboxTabs1 = new List<Checkbox> {checkboxTab1};
Radio radio1 = new Radio
{
AnchorString = "/field1/",
AnchorXOffset = "185",
AnchorYOffset = "30",
FontSize = "Size14",
Selected = "true"
};
List<Radio> radios1 = new List<Radio> {radio1};
RadioGroup radioGroupTab1 = new RadioGroup
{
Radios = radios1
};
List<RadioGroup> radioGroupTabs1 = new List<RadioGroup> {radioGroupTab1};
SenderName senderNameTab1 = new SenderName
{
AnchorString = "/field1/ ",
AnchorXOffset = "90",
AnchorYOffset = "58",
Font = "Garamond",
FontColor = "DarkGreen",
FontSize = "Size12"
};
List<SenderName> senderNameTabs1 = new List<SenderName> {senderNameTab1};
SenderCompany senderCompanyTab1 = new SenderCompany
{
AnchorString = "/field1/ ",
AnchorXOffset = "310",
AnchorYOffset = "58",
Font = "Garamond",
FontColor = "DarkGreen",
FontSize = "Size12"
};
List<SenderCompany> senderCompanyTabs1 = new List<SenderCompany> {senderCompanyTab1};
PrefillTabs prefillTabs1 = new PrefillTabs
{
CheckboxTabs = checkboxTabs1,
RadioGroupTabs = radioGroupTabs1,
SenderCompanyTabs = senderCompanyTabs1,
SenderNameTabs = senderNameTabs1,
TextTabs = textTabs1
};
Tabs tabs2 = new Tabs
{
PrefillTabs = prefillTabs1
};
Document document1 = new Document
{
DocumentId = "1",
FileExtension = "pdf",
DocumentBase64 = ReadContent("anchorfields.pdf"), // filename is anchorfields.pdf
Name = "Example document",
Tabs = tabs2
};
List<Document> documents1 = new List<Document> {document1};
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
{
Documents = documents1,
EmailSubject = "Please sign the attached document",
Recipients = recipients1,
Status = "sent"
};
ApiClient apiClient = new ApiClient(basePath);
apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
try
{
EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);
Console.WriteLine($"Envelope status: {results.Status}. Envelope ID: {results.EnvelopeId}");
return results.EnvelopeId;
}
catch (ApiException e)
{
Console.WriteLine("Exception while creating envelope!");
Console.WriteLine($"Code: {e.ErrorCode}\nContent: {e.ErrorContent}");
//Console.WriteLine(e.Message);
return "";
}
}
我试图在发送电子邮件之前设置预填字段,但它似乎不起作用。我有两个带有数据标签 fee
和 otherFee
.
尝试发送时,程序抛出以下错误:
{"errorCode":"REQUIRED_TAB_INCOMPLETE","message":"A Required field is incomplete. TabId: 0dfdf411-cafa-441e-b6e4-ef617e12de92"}
TabId
此处随每次调用而变化。我知道它必须与我的预填字段相关联,因为当我删除它们或删除 Mandatory
属性时,通过网站上的模板工具可以毫无问题地发送电子邮件。不确定为什么我得到这个唯一标识符而不是它们实际设置的数据标签。
我的代码:
//prepare client
var apiClient = new ApiClient(basePath);
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
var envelopesApi = new EnvelopesApi(apiClient);
//Make the envelope
TemplateRole signer1 = new TemplateRole
{
Email = signerEmail,
Name = signerName,
RoleName = "merchant",
};
EnvelopeDefinition envelope = new EnvelopeDefinition
{
TemplateId = templateId,
TemplateRoles = new List<TemplateRole> { signer1 },
Status = "created"
};
EnvelopeSummary result = envelopesApi.CreateEnvelope(accountId, envelope);
//set fields
Text fee = new Text {TabLabel = "fee", Value = "[=10=].50"};
Text otherFee = new Text {TabLabel = "otherFee", Value = ".77"};
PrefillTabs prefillTabs = new PrefillTabs {TextTabs = new List<Text> {fee, otherFee}};
Tabs tabs = new Tabs {PrefillTabs = prefillTabs};
var res = envelopesApi.CreateDocumentTabs(accountId, result.EnvelopeId, "1", tabs);
//update and send
Envelope envInfo = new Envelope();
envInfo.Status = "sent";
envelopesApi.Update(accountId, result.EnvelopeId, envInfo);
非常感谢任何帮助,这让我发疯了。
您可以使用预填充标签,这里是 live example。
您的问题 是您试图为模板设置 pre-fill 选项卡。那是不支持的。相反,使用常规选项卡并将它们标记为只读。 API Request Builder 有许多模板代码示例,您可以现场试用。
如上所述,您不能为服务器模板中的文档设置预填充选项卡。参见 templates post
预填充标签更适合使用 DocuSign 网络应用程序 发送 信封(交易)的人。您的 API 集成应用程序可以在 read-only 模式下使用常规选项卡。
这里是 JSON 和来自 API Request Builder 的预填充选项卡的 C# 示例。
"envelopeDefinition": {
"emailSubject": "Please sign the attached document",
"status": "sent",
"documents": [
{
"filename": "anchorfields.pdf",
"name": "Example document",
"fileExtension": "pdf",
"documentId": "1",
"tabs": {
"prefillTabs": {
"textTabs": [
{
"anchorString": "/field1/ ",
"bold": "true",
"font": "Garamond",
"fontColor": "BrightBlue",
"fontSize": "Size14",
"value": "This field and the following are all \"prefill\" fields: "
},
{
"anchorString": "/field1/ ",
"anchorXOffset": "0",
"anchorYOffset": "30",
"bold": "true",
"font": "Garamond",
"fontColor": "Black",
"fontSize": "Size12",
"value": "Checkbox:"
},
{
"anchorString": "/field1/ ",
"anchorXOffset": "90",
"anchorYOffset": "30",
"bold": "true",
"font": "Garamond",
"fontColor": "Black",
"fontSize": "Size12",
"value": "Radio button:"
},
{
"anchorString": "/field1/ ",
"anchorXOffset": "0",
"anchorYOffset": "60",
"bold": "true",
"font": "Garamond",
"fontColor": "Black",
"fontSize": "Size12",
"value": "Sender name:"
},
{
"anchorString": "/field1/ ",
"anchorXOffset": "190",
"anchorYOffset": "60",
"bold": "true",
"font": "Garamond",
"fontColor": "Black",
"fontSize": "Size12",
"value": "Sender company:"
}
],
"checkboxTabs": [
{
"anchorString": "/field1/ ",
"anchorXOffset": "70",
"anchorYOffset": "30",
"fontSize": "Size14",
"selected": "true"
}
],
"radioGroupTabs": [
{
"radios": [
{
"anchorString": "/field1/",
"anchorXOffset": "185",
"anchorYOffset": "30",
"selected": "true",
"fontSize": "Size14"
}
]
}
],
"senderNameTabs": [
{
"anchorString": "/field1/ ",
"anchorXOffset": "90",
"anchorYOffset": "58",
"font": "Garamond",
"fontColor": "DarkGreen",
"fontSize": "Size12"
}
],
"senderCompanyTabs": [
{
"anchorString": "/field1/ ",
"anchorXOffset": "310",
"anchorYOffset": "58",
"font": "Garamond",
"fontColor": "DarkGreen",
"fontSize": "Size12"
}
]
}
}
}
],
"recipients": {
"signers": [
{
"email": "signer_email@example.com",
"name": "Signer's name",
"recipientId": "1",
"clientUserId": "1000",
"tabs": {
"signHereTabs": [
{
"anchorString": "/sig1/",
"anchorXOffset": "20",
"anchorUnits": "pixels"
}
]
}
}
]
}
}
C#
static string SendDocuSignEnvelope()
{
SignHere signHereTab1 = new SignHere
{
AnchorString = "/sig1/",
AnchorUnits = "pixels",
AnchorXOffset = "20"
};
List<SignHere> signHereTabs1 = new List<SignHere> {signHereTab1};
Tabs tabs1 = new Tabs
{
SignHereTabs = signHereTabs1
};
Signer signer1 = new Signer
{
ClientUserId = "1000",
Email = "signer_email@example.com",
Name = "Signer's name",
RecipientId = "1",
Tabs = tabs1
};
List<Signer> signers1 = new List<Signer> {signer1};
Recipients recipients1 = new Recipients
{
Signers = signers1
};
Text textTab1 = new Text
{
AnchorString = "/field1/ ",
Bold = "true",
Font = "Garamond",
FontColor = "BrightBlue",
FontSize = "Size14",
Value = "This field and the following are all ""prefill"" fields: "
};
Text textTab2 = new Text
{
AnchorString = "/field1/ ",
AnchorXOffset = "0",
AnchorYOffset = "30",
Bold = "true",
Font = "Garamond",
FontColor = "Black",
FontSize = "Size12",
Value = "Checkbox:"
};
Text textTab3 = new Text
{
AnchorString = "/field1/ ",
AnchorXOffset = "90",
AnchorYOffset = "30",
Bold = "true",
Font = "Garamond",
FontColor = "Black",
FontSize = "Size12",
Value = "Radio button:"
};
Text textTab4 = new Text
{
AnchorString = "/field1/ ",
AnchorXOffset = "0",
AnchorYOffset = "60",
Bold = "true",
Font = "Garamond",
FontColor = "Black",
FontSize = "Size12",
Value = "Sender name:"
};
Text textTab5 = new Text
{
AnchorString = "/field1/ ",
AnchorXOffset = "190",
AnchorYOffset = "60",
Bold = "true",
Font = "Garamond",
FontColor = "Black",
FontSize = "Size12",
Value = "Sender company:"
};
List<Text> textTabs1 = new List<Text> {textTab1, textTab2, textTab3, textTab4, textTab5};
Checkbox checkboxTab1 = new Checkbox
{
AnchorString = "/field1/ ",
AnchorXOffset = "70",
AnchorYOffset = "30",
FontSize = "Size14",
Selected = "true"
};
List<Checkbox> checkboxTabs1 = new List<Checkbox> {checkboxTab1};
Radio radio1 = new Radio
{
AnchorString = "/field1/",
AnchorXOffset = "185",
AnchorYOffset = "30",
FontSize = "Size14",
Selected = "true"
};
List<Radio> radios1 = new List<Radio> {radio1};
RadioGroup radioGroupTab1 = new RadioGroup
{
Radios = radios1
};
List<RadioGroup> radioGroupTabs1 = new List<RadioGroup> {radioGroupTab1};
SenderName senderNameTab1 = new SenderName
{
AnchorString = "/field1/ ",
AnchorXOffset = "90",
AnchorYOffset = "58",
Font = "Garamond",
FontColor = "DarkGreen",
FontSize = "Size12"
};
List<SenderName> senderNameTabs1 = new List<SenderName> {senderNameTab1};
SenderCompany senderCompanyTab1 = new SenderCompany
{
AnchorString = "/field1/ ",
AnchorXOffset = "310",
AnchorYOffset = "58",
Font = "Garamond",
FontColor = "DarkGreen",
FontSize = "Size12"
};
List<SenderCompany> senderCompanyTabs1 = new List<SenderCompany> {senderCompanyTab1};
PrefillTabs prefillTabs1 = new PrefillTabs
{
CheckboxTabs = checkboxTabs1,
RadioGroupTabs = radioGroupTabs1,
SenderCompanyTabs = senderCompanyTabs1,
SenderNameTabs = senderNameTabs1,
TextTabs = textTabs1
};
Tabs tabs2 = new Tabs
{
PrefillTabs = prefillTabs1
};
Document document1 = new Document
{
DocumentId = "1",
FileExtension = "pdf",
DocumentBase64 = ReadContent("anchorfields.pdf"), // filename is anchorfields.pdf
Name = "Example document",
Tabs = tabs2
};
List<Document> documents1 = new List<Document> {document1};
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
{
Documents = documents1,
EmailSubject = "Please sign the attached document",
Recipients = recipients1,
Status = "sent"
};
ApiClient apiClient = new ApiClient(basePath);
apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
try
{
EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);
Console.WriteLine($"Envelope status: {results.Status}. Envelope ID: {results.EnvelopeId}");
return results.EnvelopeId;
}
catch (ApiException e)
{
Console.WriteLine("Exception while creating envelope!");
Console.WriteLine($"Code: {e.ErrorCode}\nContent: {e.ErrorContent}");
//Console.WriteLine(e.Message);
return "";
}
}