Docusign : Unable to create envelope from document in restapi v2

半城伤御伤魂 提交于 2019-12-25 02:11:59

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/20478727/docusign-unable-to-create-envelope-from-document-in-restapi-v2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!