0

I have an envelope that consists of compositeTemplate. There are 2 inlinteTemplates, first one contain some documents. I want to replace one of the documents. Is there any REST API that I can use and send JSON to replace the document? Example: Documents 1, 2, 3 are in a composite template. Envelope has been sent to recipient. Document 3 is a HTML document which needs to be replaced by another HTML document. I found a post that says how to replace but I don't know which REST API to call to implement this. DocuSign Rest API to replace single template document

With no clue to replace, I have tried following but did not work PUT /v2.1/accounts/{accountId}/envelopes/{envelopeId}/attachments

1 Answers1

0

You do need a PUT but to a slightly different endpoint.

see documentation here - https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeDocuments/update

PUT /v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}

Now finding the documentId may require you to make a GET call first to retrieve the envelope and all the documents.

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
  • The documentation says include "Content-Deposition" in header but when tried to make PUT call, getting error "XMLHttpRequest":"Content-Deposition" is not a valid HTML header field name. – Mohammad Khan Oct 28 '19 at 19:05
  • what value did you use for this header? – Inbar Gazit Oct 28 '19 at 19:16
  • I recommend you use the SDK to make it easier for you. – Inbar Gazit Oct 28 '19 at 19:16
  • The value I put in header "Content-Deposition" is following, file; filename='test.pdf';documentid=1 But, I feel, the issue is not the VALUE. It says "XMLHttpRequest":"Content-Deposition" is not a valid HTML header field name. – Mohammad Khan Oct 28 '19 at 21:31
  • and your document is called test.pdf? – Inbar Gazit Oct 28 '19 at 21:33
  • did you put the correct extension and the correct documentId? – Inbar Gazit Oct 28 '19 at 21:33
  • The extension and doucmentId both are correct. (DocumentID was via GET call). The error is not even regarding the file or extension. It says the Content-Disposition is not a valid HTML header. – Mohammad Khan Oct 29 '19 at 04:35
  • is there any chance you can use an SDK? what coding language are you using? – Inbar Gazit Oct 29 '19 at 16:08
  • I am not using any SDK. The language we are using is RPG (on iSeries formally known as AS400). But irrespective of language, the JSON that we write and submit to docusign is same. For example, I sent following and I get successful response. Yet I can't see what got attached to envelope versus if I attach a document using "signerAttachment" tab it gets physically appended. – Mohammad Khan Oct 31 '19 at 18:12
  • { "status": "sent", "emailSubject": "Please sign", "recipients": {}, "attachments": [ { "attachmentId": "9", "label": "some label", "attachmentType": "html", "name": "some name", "accessControl": "senderAndAllRecipients", "data":"PGh0bWw+Cjxib2R5PgogYXNkbGZqCjwvYm9keT4KPC9odG1sPg==", "remoteUrl": "sample string 7" } ] } – Mohammad Khan Oct 31 '19 at 18:18
  • these are two different things. An envelope can include an attachment, and that is sent by a recipient, or you have the actual documents, that are sent by the sender. Which one are you trying to add/replace? – Inbar Gazit Oct 31 '19 at 20:15
  • When including attachment via REST API, I don't see the document. Had I put a signerAttachment tab, user could have attached the additional document and got it physically appended. Secondly, I tried to include a document at time of create of envelope and tried to replace with that additional document. But that did not work either. My goal is to create the envelope with, say, 2 documents in compositeTemplate and send to a signer. When signer opens and signs, I want to add a third document before the next recipient get the envelope. So the next person would see 3 documents versus 2. – Mohammad Khan Nov 02 '19 at 13:53
  • don't use an attachment via REST API. Add another document like I explained above. like I said, attachments are for signers, you are the sender, don't use attachments. – Inbar Gazit Nov 04 '19 at 16:58
  • I was able to add document to envelope using following API. I had to set up header with " content-disposition : filename.html " PUT /v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId} Thank you @InbarGazit for putting me to the right direction. – Mohammad Khan Nov 19 '19 at 18:24