2016-08-24 59 views
0

我的cURL有點生疏,但我試圖做一個簡單的測試並重新創建'基本場景' - '從文檔創建一個信封'從V2 REST api文檔中,用簡單的一個頁面.docx文件。DocuSign,cURL,json - 來自bash - 錯誤:ENVELOPE_IS_INCOMPLETE

這裏是我的curl命令:

curl -X POST https://demo.docusign.net/restapi/v2/accounts/xxx/envelopes \ 
-H "X-DocuSign-Authentication: \ 
<DocuSignCredentials><Username>me/Username><Password>pp</Password><IntegratorKey>...</IntegratorKey></DocuSignCredentials>" \ 
-H "Accept: application/json" \ 
-H "Content-Type: multipart/form-data; boundary=AAA" \ 
-d '--AAA \ 
Content-Type: application/json \ 
Content-Disposition: form-data \ 
\ 
{ \ 
"status":"sent", \ 
"emailBlurb":"Test Email Body", \ 
"emailSubject": "Test Email Subject EnvelopeDefFull", \ 
"documents": [{ \ 
     "name": "test1.docx", \ 
     "documentId":"1", \ 
     "order":"1" \ 
}], \ 
"recipients": { \ 
"signers" : [{ \ 
     "email": "[email protected]", \ 
     "name": "my name", \ 
     "recipientId":"1" \ 
}] \ 
} \ 
--AAA \ 
Content-Type: application/docx \ 
Content-Disposition: file; filename="test1.docx"; documentid=1 \ 
\ 
@test1.docx \ 
\ 
--AAA--' 

和我得到的錯誤是:

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

這是犯罪嫌疑人是不是真正的問題。

我想我有捲曲問題

可能出現的問題:-d單引號 內 (1)反斜槓(2)通過事先@

感謝DOCX型和包容!

回答

0

我不能讓你的捲曲的要求要麼工作,但這裏是一個演示發送有效載荷的另一種方式的鏈接:https://docs.docusign.com/esign/guide/usage/request_a_signature.html

有一點需要指出的(雖然不影響當前的誤差)確保,包括文檔中的fileExtension,否則假定爲一個PDF:

"documents": [{ 
    "name": "test1.docx", 
    "documentId":"1", 
    "order":"1", 
    "fileExtension" : "docx" 
}], 
1

它與你的空間做(和你缺少你的JSON部分})。

如果您採用相同的請求並將其放入郵遞員中,請刪除所有尾隨空格。它工作得很好。

0

好吧,事實證明我有很多錯誤,Andrew和Nick都是對的。爲了完整起見,這裏是我最終的工作解決方案。

第一,bash腳本:

curl -X POST --upload-file send.txt \ 
https://na2.docusign.net/restapi/v2/accounts/xxx/envelopes \ 
-H "Accept: application/json" \ 
-H "Content-Type: multipart/form-data; boundary=AAA" \ 
-H "X-DocuSign-Authentication: \ 
<DocuSignCredentials><SendOnBehalfOf>...</SendOnBehalfOf><Username>..</Username><Password>...</Password><IntegratorKey>...</IntegratorKey></DocuSignCredentials>" 

現在,send.txt的內容。

請注意以下幾點:我必須將文檔轉換爲PDF,然後將PDF字節內嵌插入到文檔中,然後關閉它。當我看到尼克的解決方案時,我已經完成了。包括它通過@沒有工作,我不得不用「貓」將其追加到實際send.txt文件

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

{ 
"status":"sent", 
"emailBlurb":"...", 
"emailSubject":"Renew...", 
"compositeTemplates":[{ 
     "serverTemplates": [{ 
       "sequence":1, 
       "templateId":"xxxx", 
       "templateRoles":[ 
       ] 
     }], 
     "inlineTemplates":[{ 
       "sequence":2, 
       "recipients": { 
         "signers" : 
           [{ 
           "email": "[email protected]", 
           "name": "...", 
           "recipientId": "1", 
           "accessCode": "xxxx", 
           "roleName": "..." 
           },] 
         }, 
     }], 
"document": { 
     "name": "Renew.pdf", 
     "documentId":"1", 
}, 
}],"notification": { 
     "UseAccountDefaults":"false", 
     "reminders": { 
       "reminderEnabled": "true", 
       "reminderDelay": "3", 
       "reminderFrequency": "10" 
     }, 
     "expirations": { 
       "expireEnabled": "true", 
       "expireAfter": "7", 
       "expireWarn": "1" 
     }, 
}, 
} 

--AAA 
Content-Type: application/pdf 
Content-Disposition: file; filename="Renew.pdf"; documentid=1 

%PDF-1.4^M%âãÏÓ^M1 0 obj 
<< 
...pdf bytes here... 
/Info 29 0 R 
>> 
startxref 
84324 
%%EOF 

--AAA-- 

我不得不做出特定於該應用程序模板,更簡單,更容易膨脹或收縮,這樣簽名標籤可以放置在文檔上的絕對座標而不是錨定。交互使用的常規模板無法正常工作。

最後,HTML標題必須完全按照換行符來修正,一個額外的或丟失的,並且失敗。再次

感謝您的幫助

亞光