1

I've been working on integrating the DocuSign REST API into my company's app. Things are mostly working, but there is still one problem. If I upload multiple (>= 2) documents, each with an associated server template, then all of the templates end up getting applied to the first document.

For example, the following API call to /accounts/account_id/envelopes should upload two documents: document1.pdf (7 pages) and document2.pdf (2 pages). document1.pdf's server template has a sign-here field on the 7th page and document2.pdf's server template has a sign-here field on the 2nd page.

What appears on the DocuSign website is an envelope with the two documents correctly uploaded, but with document2.pdf's sign-here field appearing on page 2 of document1.pdf. If I manually remove and reapply the template on document2.pdf, then the field gets correctly placed. I suspect this is due to a subtle problem with my sequence attributes, but I have been unable to figure out exactly what is wrong.

{
  "allowReassign": false,
  "emailBlurb": "email text",
  "emailSubject": "subject",
  "status": "created",
  "compositeTemplates": [
    {
      "document": {
        "name": "document1.pdf",
        "documentId": "1"
      },
      "serverTemplates": [
        {
          "sequence": "1",
          "templateId": "12345678-abcd-1234-abcd-1234567890ab"
        }
      ],
      "inlineTemplates": [
        {
          "sequence": "1",
          "recipients": {
            "signers": [
              {
                "name": "Test Primary",
                "email": "test@example.com",
                "recipientId": "1",
                "routingOrder": "1",
                "roleName": "RoleOne"
              }
            ]
          }
        }
      ]
    },
    {
      "document": {
        "name": "document2.pdf",
        "documentId": "2"
      },
      "serverTemplates": [
        {
          "sequence": "2",
          "templateId": "abcdef12-1234-abcd-1234-abcdef123456"
        }
      ],
      "inlineTemplates": [
        {
          "sequence": "2",
          "recipients": {
            "signers": [
              {
                "name": "Test Primary",
                "email": "test@example.com",
                "recipientId": "1",
                "routingOrder": "1",
                "roleName": "RoleOne"
              }
            ]
          }
        }
      ]
    }
  ]
}
Larry K
  • 47,808
  • 15
  • 87
  • 140

3 Answers3

2

This issue in this example is not the sequence. It is the documentId's for the documents passed in.

When a server side template is created, think of it as having documentId=1. In this case, two server side templates are used, one for each composite template section and each has documentId=1. Tabs placed on these template documents are associated with documentId=1. The documentId of the document passed for each composite template in should also be documentId=1 so when that document overlays, the ID matches.

The example sets the second document passed in as documentId=2. So, when the envelope/template info is folded together, the tabs retain the association with documentId=1, so they appear on page 2 and page 7 of the first document, The second template is overlaid with documentId 2, so it will not have any tabs.

If the passed-in document for both composite templates uses documentId=1, the tabs will properly associate within each composite template, and then the documentID's will be reordered in the final envelope along with tab Id’s.

The sequence numbers can be 1,2,3,4 or 1,2 in the first composite template, and 1,2 in the second.

Working example:

POST http://localhost/restapi/v2/accounts/2/envelopes
X-DocuSign-Authentication: [omitted]
Accept: application/json
Content-Type: multipart/form-data; boundary=70fcb373-f40d-40bb-bddb-204fe789087f
X-DocuSign-ClientTransactionId: T635316112162595227

--70fcb373-f40d-40bb-bddb-204fe789087f
Content-Type: application/json
Content-Disposition: form-data

{
  "compositeTemplates": [
      {
        "compositeTemplateId": "1",
        "serverTemplates": [
          {
            "sequence": "1",
            "templateId": "99B09A06-95AF-47A5-964B-A58E78B981DF"
          }
        ],
        "inlineTemplates": [
          {
            "sequence": "1",
            "recipients": {
              "signers": [
                {
                  "name": "Resty Tester",
                  "email": "resty.tester@gmail.com",
                  "recipientId": "1",
                  "routingOrder": "1",
                  "roleName": "RoleOne"
                }
              ]
            }
          }
        ],
        "document": {
          "documentId": "1",
          "name": "document1In.pdf"
        }
      },
      {
        "compositeTemplateId": "2",
        "serverTemplates": [
          {
            "sequence": "2",
            "templateId": "36FD0433-AAE0-43A7-B795-E06738159A59"
          }
        ],
        "inlineTemplates": [
          {
            "sequence": "2",
            "recipients": {
              "signers": [
                {
                  "name": "Resty Tester",
                  "email": "resty.tester@gmail.com",
                  "recipientId": "1",
                  "routingOrder": "1",
                  "roleName": "RoleOne"
                }
              ]
            }
          }
        ],
        "document": {
          "documentId": "1",
          "name": "document2In.pdf"
        }
      }
    ],
    "status": "created",
    "emailSubject": "Subject PostCompositeTemplate_PLAT_1647_20140328014654",
    "emailBlurb": "Blurb PostCompositeTemplate_PLAT_1647_20140328014654",
    "allowReassign": "false"
  }
  --70fcb373-f40d-40bb-bddb-204fe789087f
  Content-Type: application/pdf
  Content-Disposition: file; filename="document1In.pdf"; documentId=1;             compositeTemplateId="1"
  Content-Transfer-Encoding: base64

  [bytes omitted]
  --70fcb373-f40d-40bb-bddb-204fe789087f
  Content-Type: application/pdf
  Content-Disposition: file; filename="document2In.pdf"; documentId=1; compositeTemplateId="2"
  Content-Transfer-Encoding: base64

  [bytes omitted]
  --70fcb373-f40d-40bb-bddb-204fe789087f--
  201 Created
  Pragma: no-cache
  X-DocuSign-ClientTransactionId: T635316112162595227
  Content-Length: 198
  Cache-Control: no-cache
  Content-Type: application/json; charset=utf-8
  Date: Fri, 28 Mar 2014 20:46:58 GMT
  Expires: -1

  {
    "envelopeId": "5b28e38e-84c0-4af0-a3d0-e3c1e6cee17d",
    "uri": "/envelopes/5b28e38e-84c0-4af0-a3d0-e3c1e6cee17d",
    "statusDateTime": "2014-03-28T20:46:57.4300000Z",
    "status": "created"
  }
Laurel
  • 96
  • 5
0

With regards to the sequence see my question here. The sequence number should denote the object sequence within the scope of the current composite template. I increment my seq# for the inline templates and it works fine. That being said, it may not be the issue with regards to the sig page being appended improperly. I'd start there, however. Hope this helps.

Community
  • 1
  • 1
Todd
  • 459
  • 5
  • 18
0

I've successfully repro'd the issue you describe, and have tried remedying the issue by using various combinations of sequence value, all to no avail. This seems like a bug to me.

Kim Brandl
  • 13,125
  • 2
  • 16
  • 21
  • Ah, I was dreading that. I've been looking around for where to report bugs to DocuSign, but I haven't been able to find their bug tracker. Do you happen to know where I can find that? Thanks. – user3022871 Nov 22 '13 at 23:10
  • I don't believe there's a public-facing bug tracker for DocuSign API issues. Their people participate frequently in this stackoverflow forum though, so hopefully they'll see this post and respond accordingly. – Kim Brandl Nov 22 '13 at 23:49
  • I'm unable to reproduce this issue so far. I'll try a couple of other things, but I also want to confirm something here. In your JSON you are setting the same `recipientId`, `routingOrder`, and `name` for your two recipients, however you are providing a different `email` address for them. What is your intended use-case here, is this supposed to be the same recipient, or two different ones? – Ergin Dec 03 '13 at 19:29
  • My apologies for taking so long on this. The emails were intended to be the same but I must have mistyped them when building the JSON. I've edited the JSON to reflect this. As for the use-case, it was meant to upload two customized documents to be sent to one user, each with a different server template applied. – user3022871 Jan 11 '14 at 00:50