0

I am trying to add a PDF document to an existing draft envelope by using a CompositeTemplate so DocuSign can convert the PDF fields to tabs automatically for me. Unfortunately the request fails with a HTTP code 400 and the following response:

{"errorCode":"INVALID_MULTI_PART_REQUEST","message":"An error was found while parsing the multipart request. No documents found in request."}

This error makes no sense to me since I am specifying the document by using the documentBase64 property so it should not be using multipart.

I am calling PUT .../accounts/???/envelopes/???/documents with a body of:

{
  "compositeTemplates" : [ {
    "document" : {
      "documentBase64" : "...",
      "documentId" : "200",
      "name" : "document.pdf",
      "transformPdfFields" : "true"
    },
    "inlineTemplates" : [ {
      "recipients" : {
        "signers" : [ {
          "defaultRecipient" : "true",
          "email" : "jdoe@domain.test",
          "name" : "John Doe",
          "recipientId" : "1"
        } ]
      },
      "sequence" : "1"
    } ]
  } ]
}

Adding documents to the envelope works fine if I don't use a CompositeTemplate and just put the document directly in the documents attribute at the top level of the request JSON. Unfortunately, responses to other questions in stackoverflow seem to indicate that transformPdfFields only works when the document is inside a CompositeTemplate (and indeed it didn't convert PDF fields to tabs when I tried it that way).

Aner
  • 560
  • 4
  • 13
  • I'm not aware of the need to use compositeTemplate to use transformPdfFields. Did you try to do it w/o a template? – Inbar Gazit Jul 11 '23 at 22:02
  • Why don't you create the envelope with the PDF and transformPdfFields to begin with? – Inbar Gazit Jul 11 '23 at 22:03
  • I did try setting transformPdfFields directly on the document without using a template but no tabs were actually added when looking in the envelope. This was a while back on my first attempt to do this so it may be worth a shot to try it again. – Aner Jul 12 '23 at 13:10
  • We need to add documents to the envelope as they become available so we can't do this at envelope creation time. – Aner Jul 12 '23 at 13:16
  • I stand corrected, I tried again without using templates and it worked perfectly. The last time I tried this was a few months back and the tabs were not being created. Either I did something different in my code this time or there was an issue in the api at that time. I was trying the template approach based on replies to an older question [Creating Template with Transformed PDF Form Fields](https://stackoverflow.com/q/34213363) – Aner Jul 12 '23 at 14:01
  • I'll post this as an answer then – Inbar Gazit Jul 12 '23 at 16:21

1 Answers1

0

There's no need to use a composite template for PDF Transform fields. If this was posted somewhere else in Stackoverflow - let me know and I'll correct it.

You can just set "transformPdfFields" : "true" at any envelope and it should work just fine.

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23