0
votes

Need help on how to create a template using docusign api, c#, xml

I'm getting an error message as - '(404) Bad Request'

url = https://demo.docusign.net/restapi/v2/accounts/{......}/templates

string requestBody =
        "<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
        "<emailSubject>Please sign this Document</emailSubject>" +
        "<status>sent</status>" +                           
        // add document(s)
        "<documents>" +
        "<document>" +
        "<documentId>1</documentId>" +
        "<name>document.pdf</name>" +
        "</document>" +
        "</documents>" +
        // add recipient(s)
        "<recipients>" +
        "<signers>" +
        "<signer>" +
        "<recipientId>1</recipientId>" +
        "<email>[email protected]</email>" +
        "<name>Som Smith</name>" +
        "<roleName>Signer</roleName>" +
        "<tabs>" +
          "<signHereTabs>" +
          "<signHere>" +
            "<xPosition>70</xPosition>" + 
            "<yPosition>560</yPosition>" + 
            "<documentId>1</documentId>" +
            "<pageNumber>2</pageNumber>" +
          "</signHere>" +
          "</signHereTabs>" +
        "</tabs>" +
        "</signer>" +
        "</signers>" +
        "</recipients>" +
        "<envelopeTemplateDefinition>" +
            "<name>TestTemplate</name>" +
            "<owner>" +
                "<email>[email protected]</email>" +
            "</owner>" +
        "</envelopeTemplateDefinition>" +
        "</envelopeDefinition>";

The Response error message i'm getting

<errorDetails xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">errorCode>UNSPECIFIED_ERROR</errorCode><message>There is an error in XML document (1, 2).</message></errorDetails>

Much appreciated

1

1 Answers

0
votes

The request body you are using is for sending a signature request from an existing template, not for creating a new template in your account. To create a new template through the API you need a different request body. You can use the auto-generated REST API help page:

https://www.docusign.net/restapi/help

Scroll down and find POST call for creating a template and you can see a sample request body. The sample is huge since it includes all possible things that could go into that body, but you'll know how to construct your JSON (or XML).

Also see the corresponding documentation for the API call for creating a template:

POST Template