0

I am trying to pass the address and social security information that is collected from an employee into DocuSign templates I have created. I can easily send a form using the code below and have tried adding the element to pass values but this isn't working or throwing errors.

            //  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));

My templates already have all of the fields added with custom labels for the fields I would like to populate programmatically. I just can't figure out how to format the request body correctly to get these fields to be set.

Arcan.NET
  • 700
  • 4
  • 12

1 Answers1

1

You are missing the tabs xml node and you also need an extra node for each text tab. Right now you have this:

"<textTabs>" +
    "<tabLabel>street</tabLabel>" +
    "<value>" + streetAddress + "</value>" +
    "<documentId>1</documentId>" +
    "<pageNumber>1</pageNumber>" +                           
"</textTabs>" +

You need to place these under the tabs object and add a singular <text> node for for each individual text tab, ie:

"<tabs>"    
    "<textTabs>" +
        "<text>" +
            "<tabLabel>street</tabLabel>" +
            "<value>" + streetAddress + "</value>" +
            "<documentId>1</documentId>" +
            "<pageNumber>1</pageNumber>" +                           
        "</text>" +
    "</textTabs>" +
"</tabs>"
Ergin
  • 9,254
  • 1
  • 19
  • 28
  • I added the element into the code but the tab is still blank when the recipient opens the envelope. I am uncertain what the documentId and pageNumber elements should be set to. I copied these from another example I saw but don't know what vales they should have when sending a template. – Arcan.NET Jul 06 '15 at 15:17
  • 1
    Solved it with some help. Needed to add the element and insert all of it inside of the templateRole element at the end. Same thing done here: http://stackoverflow.com/questions/26344441/not-able-to-pass-in-values-to-docusign-template/26353006#26353006 – Arcan.NET Jul 06 '15 at 16:43
  • Sorry I didn't notice that at first, it was really a combination of both issues. I've updated my answer – Ergin Jul 07 '15 at 17:30
  • It would really be nice if there were more XML examples on your site since that's the default example you use for C# developers. – Arcan.NET Jul 09 '15 at 20:42
  • We will be updating the API Walkthroughs soon to use our open source SDKs, so that won't be an issue soon. Can you accept my answer so the community can benefit from this? – Ergin Jul 15 '15 at 23:22
  • Also, if you look at the Rest API Operations* link on the Dev Center [Documentation](https://www.docusign.com/developer-center/documentation) page you can see as much XML as you need, since those show all possible properties for every request. – Ergin Jul 15 '15 at 23:24
  • I don't believe there is an XML example on this in the documentation for XML. A colleague and I spent a few solid days looking around and trying to find out how to do this. We ended up having to reverse engineer a Json reference we found here on stack exchange to figure it out. – Arcan.NET Jul 17 '15 at 14:27