Thursday, 8 June 2017

Add documents to existing envelope

I am following the (LESSON 3) on https://www.docusign.com/blog/dsdev-using-docusign-rest-api-add-additional-documents-envelope/ to add additional documents to my existing draft envelope, only I am using the nodejs module http://docusign.github.io/docusign-node-client/

so I first login, and create an envelope (with envelope definition with status status: "created" instead of "sent") and then try to run "updateDocuments" as follows:

    // create a new envelope object that we will manage the signature request through
    var envDef = new docusign.EnvelopeDefinition();
    var docDef = new docusign.Document();

    docDef = [
      {
        documentId: 1,
        name: "CONTRACT",
        fileExtension: "jpg",
        documentBase64: base64_encode("./someimage.jpg")
      }
    ];
    envDef.documents = docDef;


    envelopesApi.updateDocuments(accountId, envelopeId,
      {"envelopeDefinition": envDef}
    ,function(error, data, response) {
        console.log(JSON.stringify(response,1,2));
        process.exit();
    });

console log giving the following error (FORMAT_CONVERSION_ERROR) :

{ "req": { "method": "PUT", "url": "https://demo.docusign.net/restapi/v2/accounts/2984497/envelopes/ef87c144-497a-4ce8-8d81-cd1068f90daf/documents", "data": { "documents": [ { "documentId": 1, "name": "contract", "fileExtension": "jpg", "documentBase64": "***HUGE base64 string***" } ] } }, "header": { "cache-control": "no-cache", "content-length": "291", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1496912400", "x-ratelimit-limit": "1000", "x-ratelimit-remaining": "995", "x-docusign-tracetoken": "b44c0be9-96f3-4348-8e01-04babd762691", "date": "Thu, 08 Jun 2017 08:15:46 GMT", "connection": "close", "strict-transport-security": "max-age=31536000; includeSubDomains" }, "status": 200, "text": "{\r\n \"envelopeId\": \"ef87c144-497a-4ce8-8d81-cd1068f90daf\",\r\n \"envelopeDocuments\": [\r\n {\r\n \"documentId\": \"1\",\r\n \"order\": \"8\",\r\n \"errorDetails\": {\r\n \"errorCode\": \"FORMAT_CONVERSION_ERROR\",\r\n \"message\": \"The data could not be converted.\"\r\n }\r\n }\r\n ]\r\n}" }

according to one answer I googled my content-encoding header isnt correct.. but I don't believe that as the idea is that the json-documentBase64 would be read out, instead of the multipart chunks

Any idea what I am doing wrong?

Thanks, Niels



via niels van Oord

No comments:

Post a Comment