0

I'm getting the following error when trying to send DOCX documents to docusign through the rest API Until now it has worked just fine for almost a year. I've tested it with a variety of DOCX files and all of them return this error

"errorCode": "UNABLE_TO_CONVERT_DOCUMENT", 
"message": "System was unable to convert this document to a PDF. Unable to convert Document(afasf.docx) to a PDF. 
Error: UserId:********-****-*****-*****-*********** IPAddress:***.***.***.*** 
Source:ApiRESTv2:Could not submit Document to Conversion Server: EnvelopeId:00000000-0000-0000-0000-000000000000 DocumentName:afasf.docx - 
SubmitCode: -10242\r\nCould not submit Document to Conversion Server: EnvelopeId:00000000-0000-0000-0000-000000000000 DocumentName:afasf.docx - 
SubmitCode: -10242\r\nCould not submit Document to Conversion Server: EnvelopeId:00000000-0000-0000-0000-000000000000 DocumentName:afasf.docx - 
SubmitCode: -10242\r\n"
Rudy B
  • 68
  • 4
  • 1. I would check the content-type to see if it matches application/vnd.openxmlformats-officedocument.wordprocessingml.document from StackOverflow article http://stackoverflow.com/questions/4212861/what-is-a-correct-mime-type-for-docx-pptx-etc – David W Grigsby Nov 06 '14 at 16:21
  • 2. I would always recommend posting the full json multipart request as I have seen far too many missing needed carriage returns and line feeds as well as headers below the bytes, vs after the boundary – David W Grigsby Nov 06 '14 at 16:23
  • 3. I prefer the following base64 for removing the issue of router inspection, etc but it is larger by about a 1/3. --AAA Content-Type: application/pdf Content-Disposition: file; filename="f4506t.pdf"; documentid=1 Content-Transfer-Encoding: base64 – David W Grigsby Nov 06 '14 at 16:26
  • 1
    Any chance you can update this and mark answered? – David W Grigsby Apr 07 '18 at 11:33

2 Answers2

8

I look forward to your answers from above, but here is working example in base64 of a docx

I use this online tool for encoding, decoding files to/from base64 http://www.opinionatedgeek.com/dotnet/tools/Base64Encode/

URI, Verb and Headers:

POST /restapi/v2/accounts/225705/envelopes HTTP/1.1
Host: demo.docusign.net
X-DocuSign-Authentication: your info aka userid, password and integrator key
Content-Type: multipart/form-data; boundary=AAA
Accept: application/json

Body of Post:

--AAA
Content-Type: application/json
Content-Disposition: form-data

{
    "emailBlurb": "Test for basic docx",
    "emailSubject": "Test for docx",
    "status": "sent",
    "compositeTemplates": [
        {
            "inlineTemplates": [
                {

                    "sequence": "1",
                    "documents": [
                        {
                            "documentId": "1",
                            "name": "basic.docx"
                        }
                    ],
                    "recipients": {
                        "signers": [
                            {
                                "recipientId": "1",
                                "name": "Your Name",
                                "email": "youremail@yourdomain.com",
                                "defaultRecipient": "true",
                                "tabs": {
                                    "signHereTabs": [{
                                    "anchorString": "\\Signhere\\",
                                    "tabLabel": "Sign Here 1"
                                    }]
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ]
}

--AAA
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Disposition: file; filename="basic.docx"; documentid=1
Content-Transfer-Encoding: base64

UEsDBBQABgAIAAAAIQDpURCwjQEAAMIFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC **[base64 truncated to meet StackOverflow Limit of 30000 since it was 33196 ]** FYAAGRvY1Byb3BzL2FwcC54bWxQSwUGAAAAAA0ADQBOAwAAtVgAAAAA

--AAA--
David W Grigsby
  • 1,544
  • 1
  • 13
  • 21
1

Have you tried setting the file extension?

var doc = new docusign.Document();
var base64Doc = Buffer.from(fileBytes).toString('base64');
doc.documentBase64 = base64Doc;
doc.fileExtension = 'docx';
Ben Rolfe
  • 191
  • 2
  • 7