DocuSign API C# 发送模板作为信封时如何设置文本字段的值?
DocuSign API C# How to set the value of a text field when sending out a template as an envelope?
我正在尝试将从员工处收集的地址和社会保障信息传递到我创建的 DocuSign 模板中。我可以使用下面的代码轻松发送表单,并尝试添加元素以传递值,但这不起作用或引发错误。
// STEP 1 - Login API Call (used to retrieve your baseUrl)
// Endpoint for Login api call (in demo environment):
string url = "https://demo.docusign.net/restapi/v2/login_information";
// set request url, method, and headers. No body needed for login api call
HttpWebRequest request = initializeRequest( url, "GET", null, username, password, integratorKey);
// read the http response
string response = getResponseBody(request);
// parse baseUrl value from response body
baseURL = parseDataFromResponse(response, "baseUrl");
//--- display results
Console.WriteLine("\nAPI Call Result: \n\n" + prettyPrintXml(response));
// STEP 2 - Send Signature Request from Template
// append "/envelopes" to baseURL and use for signature request api call
url = baseURL + "/envelopes";
// construct an outgoing XML formatted request body (JSON also accepted)
string requestBody =
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" +
"<emailSubject>DocuSign API - Signature Request from Template</emailSubject>" +
"<templateId>" + templateId + "</templateId>" +
"<textTabs>" +
"<tabLabel>street</tabLabel>" +
"<value>" + streetAddress + "</value>" +
"<documentId>1</documentId>" +
"<pageNumber>1</pageNumber>" +
"</textTabs>" +
"<templateRoles>" +
"<templateRole>" +
"<name>" + recipientName + "</name>" +
"<email>" + recipientEmail + "</email>" +
"<roleName>" + templateRole + "</roleName>" +
"</templateRole>" +
"</templateRoles>" +
"</envelopeDefinition>";
// set request url, method, body, and headers
request = initializeRequest( url, "POST", requestBody, username, password, integratorKey);
// read the http response
response = getResponseBody(request);
//--- display results
Console.WriteLine("\nAPI Call Result: \n\n" + prettyPrintXml(response));
我的模板已经为我想以编程方式填充的字段添加了自定义标签的所有字段。我只是不知道如何正确格式化请求正文以设置这些字段。
您缺少 tabs
xml 节点,并且每个文本选项卡还需要一个额外的节点。现在你有这个:
"<textTabs>" +
"<tabLabel>street</tabLabel>" +
"<value>" + streetAddress + "</value>" +
"<documentId>1</documentId>" +
"<pageNumber>1</pageNumber>" +
"</textTabs>" +
您需要将它们放在 tabs
对象下,并为每个单独的文本选项卡添加一个单一的 <text>
节点,即:
"<tabs>"
"<textTabs>" +
"<text>" +
"<tabLabel>street</tabLabel>" +
"<value>" + streetAddress + "</value>" +
"<documentId>1</documentId>" +
"<pageNumber>1</pageNumber>" +
"</text>" +
"</textTabs>" +
"</tabs>"
我正在尝试将从员工处收集的地址和社会保障信息传递到我创建的 DocuSign 模板中。我可以使用下面的代码轻松发送表单,并尝试添加元素以传递值,但这不起作用或引发错误。
// STEP 1 - Login API Call (used to retrieve your baseUrl)
// Endpoint for Login api call (in demo environment):
string url = "https://demo.docusign.net/restapi/v2/login_information";
// set request url, method, and headers. No body needed for login api call
HttpWebRequest request = initializeRequest( url, "GET", null, username, password, integratorKey);
// read the http response
string response = getResponseBody(request);
// parse baseUrl value from response body
baseURL = parseDataFromResponse(response, "baseUrl");
//--- display results
Console.WriteLine("\nAPI Call Result: \n\n" + prettyPrintXml(response));
// STEP 2 - Send Signature Request from Template
// append "/envelopes" to baseURL and use for signature request api call
url = baseURL + "/envelopes";
// construct an outgoing XML formatted request body (JSON also accepted)
string requestBody =
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" +
"<emailSubject>DocuSign API - Signature Request from Template</emailSubject>" +
"<templateId>" + templateId + "</templateId>" +
"<textTabs>" +
"<tabLabel>street</tabLabel>" +
"<value>" + streetAddress + "</value>" +
"<documentId>1</documentId>" +
"<pageNumber>1</pageNumber>" +
"</textTabs>" +
"<templateRoles>" +
"<templateRole>" +
"<name>" + recipientName + "</name>" +
"<email>" + recipientEmail + "</email>" +
"<roleName>" + templateRole + "</roleName>" +
"</templateRole>" +
"</templateRoles>" +
"</envelopeDefinition>";
// set request url, method, body, and headers
request = initializeRequest( url, "POST", requestBody, username, password, integratorKey);
// read the http response
response = getResponseBody(request);
//--- display results
Console.WriteLine("\nAPI Call Result: \n\n" + prettyPrintXml(response));
我的模板已经为我想以编程方式填充的字段添加了自定义标签的所有字段。我只是不知道如何正确格式化请求正文以设置这些字段。
您缺少 tabs
xml 节点,并且每个文本选项卡还需要一个额外的节点。现在你有这个:
"<textTabs>" +
"<tabLabel>street</tabLabel>" +
"<value>" + streetAddress + "</value>" +
"<documentId>1</documentId>" +
"<pageNumber>1</pageNumber>" +
"</textTabs>" +
您需要将它们放在 tabs
对象下,并为每个单独的文本选项卡添加一个单一的 <text>
节点,即:
"<tabs>"
"<textTabs>" +
"<text>" +
"<tabLabel>street</tabLabel>" +
"<value>" + streetAddress + "</value>" +
"<documentId>1</documentId>" +
"<pageNumber>1</pageNumber>" +
"</text>" +
"</textTabs>" +
"</tabs>"