Docusign : Unable to create envelope from document

2019-09-04 17:21发布

We are trying to create an envelope from a pdf document using the docusign restapi v2. We can create an envelope using XML but when we try using JSON we receive the following error from docusign.

"errorCode": "ENVELOPE_IS_INCOMPLETE",
"message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Envelope definition missing."

The entire POST we are sending is below from fiddler (with the file content removed).

POST https://demo.docusign.net/restapi/v2/accounts/xxxxx/envelopes HTTP/1.1
X-DocuSign-Authentication: {"Username":"xxxxxx","Password":"xxxxx","IntegratorKey":"xxxxxx"}
Content-Type: multipart/form-data; boundary=AAA
Accept: application/json
Host: demo.docusign.net
Content-Length: 90500
Expect: 100-continue



--AAA
Content-Type: application/json
Content-Disposition: form-data
{
  "emailBlurb": "Blurb",
  "emailSubject": "Subhject",
  "documents": [
    {
      "name": "NDA.pdf",
      "documentId": "1"
    }
  ],
  "recipients": {
    "signers": [
      {
        "tabs": {
          "signHereTabs": [
            {
              "pageNumber": "1",
              "yPosition": "1",
              "xPosition": "1",
              "documentId": "1",
              "tabId": "1",
              "name": "TabName"
            }
          ]
        },
        "routingOrder": "1",
        "recipientId": "1",
        "name": "Ben",
        "email": "ben@test.com"
      }
    ]
  },
  "status": "created"
}
--AAA
Content-Type: application/pdf
Content-Disposition: file; filename="NDA.pdf"; documentId="1"

<pdf file image content goes here>

    --AAA--

As far as I can tell the JSON looks correct. Is there anything wrong that we are missing here?

标签: docusignapi
2条回答
Root(大扎)
2楼-- · 2019-09-04 17:49

Your JSON looks ok, this might be due to you having an extra CRLF character or two separating your boundaries in your request body. In general this is how things need to be spaced out (each newline is a \r\n):

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

<YOUR VALID JSON GOES HERE>
--AAA
Content-Type:application/pdf
Content-Disposition: file; filename="document.pdf"; documentid=1 

<DOCUMENT BYTES GO HERE>
--AAA--

It's quite possible that extra newline you have after your document bytes is causing your issue.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-09-04 17:54

I had the same problem symptoms.

My problem was with the "Boundary terminator". Be sure to use:

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

<YOUR VALID JSON GOES HERE>
--AAA--

if you have no document in your multipart attachement

查看更多
登录 后发表回答