我想使用模板發送信封。我使用表單數據來捕獲此調用的所有必需字段。我創建了下面的對象,然後追加來添加用戶的值。然後在發送到http post之前通過JSON.stringify發送。出於某種原因,仍然得到錯誤INVALID_BODY_REQUEST{errorCode:'INVALID_REQUEST_BODY',當試圖發送信封
var data = [
{
"documents": [
{
"documentId": "27730895",
"fileExtension": "pdf",
"name": "Top Level Staging",
"order": "1"
}
],
"emailSubject": "Please Sign document",
"status": "sent",
"templateId": "4fda9b93-9c82-4f23-bd06-67f9b35f0183",
"templateRoles": [
{
"email": "",
"name": "",
"roleName": "Client",
"tabs": {
"textTabs": [
{
"documentId": "27730895",
"pageNumber": "1",
"tabLabel": "cPackage",
"value": ""
},
{
"documentId": "27730895",
"pageNumber": "1",
"tabLabel": "sDate",
"value": ""
},
{
"documentId": "27730895",
"pageNumber": "1",
"tabLabel": "pAddress",
"value": ""
},
{
"documentId": "27730895",
"pageNumber": "2",
"tabLabel": "rAmount",
"value": ""
}
]
}
}
]
}];
我創建這個和使用從表單提交的用戶數據添加它。這是我如何追加對象。
var contract_data = {
cEmail:req.body.cEmail,
FullName:req.body.cName,
pAddress:req.body.pAddress,
cAmount:req.body.cAmount,
rAmount:req.body.rAmount,
dCompleted:req.body.dCompleted,
cDate:req.body.cDate,
cPackage:req.body.cPackage
};
/data[0].templateRoles[1] = contract_data.cEmail;
data[0].templateRoles[2] = contract_data.FullName;
data[0].templateRoles[0].tabs.textTabs[0].value = contract_data.cPackage;
data[0].templateRoles[0].tabs.textTabs[1].value = contract_data.dCompleted;
data[0].templateRoles[0].tabs.textTabs[2].value = contract_data.pAdress;
data[0].templateRoles[0].tabs.textTabs[3].value = contract_data.rAmount;
我然後發送數據陣列通過JSON.stringify()像這樣
var body = JSON.stringify(data)
發送發佈請求與
request({
headers:{"X-DocuSign-Authentication":creds},
url: "https://demo.docusign.net/restapi/v2/accounts/3465212/envelopes",
json: true, // <--Very important!!!
body: body,
method: "POST",
}, function (error, response, body){
console.log(response.body);
});
是模板在CPackage,SDATE,pAddress和rAmount標籤 - 4fda9b93-9c82-4f23-bd06-67f9b35f0183?如果你想使用模板發送信封,那麼你爲什麼還要添加文檔? –
是的,這些模板在測試之後從API瀏覽器複製了對象。我沒有脫掉文檔,仍然沒有去 –