我有一个场景,我需要用户访问网站上传文档,而另一个用户必须签署此文档。
到目前为止我所做的:
Step1:通过邮箱、密码和Integratorkey登录
function(next) {
var url = "https://demo.docusign.net/restapi/v2/login_information";
var body = ""; // no request body for login api call
// set request url, method, body, and headers
var options = initializeRequest(url, "GET", body, email, password);
// send the request...
request(options, function(err, res, body) {
if(!parseResponseBody(err, res, body)) {
return;
}
baseUrl = JSON.parse(body).loginAccounts[0].baseUrl;
next(null); // call next function
});
},
我收到了有效的回复,包括有效的 accountID。
Step2:现在我正在通过这个api上传一个文档
function(next) {
var url = baseUrl + "/envelopes";
// following request body will place 1 signature tab 100 pixels to the right and
// 100 pixels down from the top left of the document that you send in the request
var body = {
"recipients": {
"signers": [{
"email": recipientEmail,
"name": recipientName,
"recipientId": 1,
"tabs": {
"signHereTabs": [{
"xPosition": "100",
"yPosition": "100",
"documentId": "1",
"pageNumber": "1"
}]
}
}]
},
"emailSubject": 'checkkkkkkkk API !!!!!',
"documents": [{
"name": "abc.pdf",
"documentId": 1,
}],
"status": "sent",
};
// set request url, method, body, and headers
var options = initializeRequest(url, "POST", body, email, password);
// change default Content-Type header from "application/json" to "multipart/form-data"
options.headers["Content-Type"] = "multipart/form-data";
// configure a multipart http request with JSON body and document bytes
options.multipart = [{
"Content-Type": "application/json",
"Content-Disposition": "form-data",
"body": JSON.stringify(body),
}, {
"Content-Type": "application/pdf",
'Content-Disposition': 'file; filename="' + documentName + '"; documentId=1',
"body": fs.readFileSync(documentName),
}
];
// send the request...
request(options, function(err, res, body) {
parseResponseBody(err, res, body);
envelopeId = JSON.parse(body).envelopeId;
console.log(envelopeId);
next(null);
});
},
作为回应,我得到了一个有效的 EnvelopeID(当然!!)
第 3 步:现在我希望另一个用户(如上面提供的收件人电子邮件/姓名)在我的网站上的嵌入视图中签署此文档, 为此我正在使用此 API http://iodocs.docusign.com/APIWalkthrough/embeddedSigning#js 但这需要上面使用的 API 未返回给我们的 templateId 和角色。这需要手动上传模板并获取模板ID,这在我的场景中是不可能的,因为我希望一切都是自动的。
谁能指导我如何进行嵌入式签名。