0
我試圖創建一個信封的休息與web api v2與C#。我可以這樣做登錄好,但是當我試圖用模板創建信封時出現此錯誤。Docusign錯誤:「ENVELOPE_IS_INCOMPLETE」,當我試圖創建一個信封C#和Json
{
"errorCode": "ENVELOPE_IS_INCOMPLETE",
"message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Content-Type does not contain boundary parameter."
}
這是我的JSON:
{
"status": "sent",
"emailSubject": "DocuSign API - Embedded Signing example",
"templateId": "96e27a15-2763-4e05-86c8-29e7b4e30f64",
"templateRoles": {
"templateRole": [
{
"email": "[email protected]",
"name": "Gustavo",
"roleName": "[email protected]",
"clientUserId": "1",
"tabs": {
"textTabs": [
{
"text": {
"tabLabel": "tabLabel1",
"value": "Value1"
}
}
]
}
}
]
},
"documents": [
{
"documentId": "1",
"name": "My First DocuSign.docx"
}
]
}
我的C#功能:
public bool Create()
{
bool result = false;
try
{
//============================================================================
// STEP 2 - Create an Envelope from Template and Send
//============================================================================
string templateId = "96e27a15-2763-4e05-86c8-29e7b4e30f64";
// append "/envelopes" to baseURL and use for signature request api call
string url = AccountManager.Instance.CurrentAccount.baseUrl + "/envelopes";
string recipientEmail = "[email protected]";
string recipientName = "Gustavo";
string templateRole = "[email protected]";
//Content-Disposition: form-data
string requestBody =
"{" +
"\"status\": \"sent\"," +
"\"emailSubject\": \"DocuSign API - Embedded Signing example\"," +
"\"templateId\": \"96e27a15-2763-4e05-86c8-29e7b4e30f64\"," +
"\"templateRoles\":{" +
"\"templateRole\": [{" +
"\"email\": \"[email protected]\"," +
"\"name\": \"Gustavo\"," +
"\"roleName\": \"[email protected]\"," +
"\"clientUserId\": \"1\"," +
"\"tabs\": {" +
"\"textTabs\": [{" +
"\"text\": {" +
"\"tabLabel\": \"tabLabel1\"," +
"\"value\": \"Value1\"" +
"}" +
"}]" +
"}" +
"}]" +
"}," +
"\"documents\":[{" +
"\"documentId\":\"1\"," +
"\"name\":\"My First DocuSign.docx\"" +
"}]" +
"}";
// string body = string.Format("Content-Disposition: form-data; boundary={0}", requestBody);
// set request url, method, body, and headers
HttpWebRequest request = HttpResponseHelper.initializeRequest(
HttpResponseHelperConstants.REQUEST_ACCEPT_JSON,
HttpResponseHelperConstants.CONTENT_TYPE_MULTIPART,
url,
"POST",
requestBody,
null,
CredentialsEntity.Instance);
// read the http response
string response = HttpResponseHelper.getResponseBody(request);
}
catch (WebException ex)
{
WebResponse errorResponse = ex.Response;
using (Stream responseStream = errorResponse.GetResponseStream())
{
StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
String errorText = reader.ReadToEnd();
// log errorText
}
throw;
}
catch (Exception ex)
{
throw new DocuSignAccountException("Error when tried to create an envelope", ex);
}
}
我使用這些示例演示了官方的DocuSign網頁的功能:initializeRequest( )和getResponseBody()。 My HttpWebRequest.Accept =「application/json」; HttpWebRequest.ContentType =「multipart/form-data」;
我需要幫助來弄清楚我在Json和/或C#代碼中錯過了什麼。