【发布时间】:2016-10-19 15:09:55
【问题描述】:
我想使用 Google 表单中的信息(在提交时)使用 Docusign api 从模板发送信封。
信封完成后,我想向同一个人发送不同的 Google Form 和 Google Doc。另外,我想在步骤完成后发送一些电子邮件。
我研究过使用适用于表单、文档和电子邮件的 Google Apps 脚本,但我不知道如何从那里运行 Docusign api。任何帮助是极大的赞赏。
更新:根据您的帮助,我提出了以下建议。当我运行下面的代码时,我收到一条错误消息:“未找到或禁用指定的积分器密钥。未指定积分器密钥。”。集成器密钥处于活动状态,但它可能与重定向 URI 或密钥有关吗?我没有设置它们。
// When Form Gets submitted
function onFormSubmit(e) {
//Get information from form and set our variables
var full_name = e.values[2];
var email_address = e.values[3];
// Send the email
var subject = "TEST trigger";
var body = "Thank you for testing" + full_name + "";
MailApp.sendEmail(email_address,
subject,
body);
// SEND DOCUSIGN ENVELOPE FROM TEMPLATE
var url = "https://demo.docusign.net/restApi/v2/accounts/<accountid>/envelopes";
var payload =
{
"emailSubject": "Please sign stuff",
"emailBlurb": "TesttextTesttextTesttextTesttextTesttext",
"templateId": "<templateID>",
"templateRoles": [
{
"roleName": "role1",
"name": full_name,
"email": email_address
},
{
"roleName": "role2",
"name": "John Doe",
"email": "JohnDoe@email.com"
},
{
"roleName": "role3",
"name": "Joe Smith",
"email": "joesmith@email.com"
}
],
"status": "sent"
}
var options =
{
"method" : "post",
"header":
{
"X-DocuSign-Authentication": "{\"Username\":\<username>\",\"Password\":\"<passwork>\",\"IntegratorKey\":\"<integratorkey>\"}"
},
"payload" : payload
};
UrlFetchApp.fetch(url, options);
}
更新:我将header 更改为headers,但现在我得到了一个不同的错误。 Ergin,正如你所说,我记录了请求。下面是错误信息。内容类型似乎有问题。
POST https://demo.docusign.net:7802/restApi/v2/accounts/<accountID>/envelopes
TraceToken: <token>
Timestamp: 2016-10-24T07:24:27.6912557Z
Content-Length: 187
Content-Type: application/x-www-form-urlencoded
Connection: Keep-alive
Host: demo.docusign.net
User-Agent: Mozilla/5.0(compatible; Google-Apps-Script)
X-DocuSign-Authentication: {"Username":"<my email address>","Password":"[omitted]","IntegratorKey":"[omitted]"}
X-BROKER-EVENT-ID: AHI413UAlYti8n93Pw-ZxoDmQoiCcwanMroRR1LDTgseOKFBkZVomEVZwdxJ-kajUMDC4NN__Z7e
X-Forwarded-For: 107.178.203.22
X-SecurityProtocol-Version: TLSv1.2
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384
emailBlurb=TesttextTesttextTesttextTesttextTesttext&templateRoles=%5BLjava.lang.Object;@17be0aa5&templateId=7078020e-49a0-42c6-b77d-368211d4a666&emailSubject=Please+sign+stuff&status=sent
415 UnsupportedMediaType
Content-Type: application/json; charset=utf-8
{
"errorCode": "INVALID_CONTENT_TYPE",
"message": "Content Type specified is not supported."
}
更新:设置内容类型后,我收到正文格式不正确的错误。见下文
POST https://demo.docusign.net:7802/restApi/v2/accounts/<accountid>/envelopes
TraceToken: 0304eb5f-1188-4880-a22c-861839f4e8d9
Timestamp: 2016-10-25T09:40:49.0423980Z
Content-Length: 187
Content-Type: application/json
Connection: Keep-alive
Host: demo.docusign.net
User-Agent: Mozilla/5.0(compatible; Google-Apps-Script)
X-DocuSign-Authentication: {"Username":"<email>","Password":"[omitted]","IntegratorKey":"[omitted]"}
X-BROKER-EVENT-ID: AHI413WWv-VgeLRQbOpMQH-Y6J-93aHL4h5phAVpXeXUqK8RsYof90Eu68CI-LkC1Ef4FM8Hac-1
X-Forwarded-For: 107.178.192.41
X-SecurityProtocol-Version: TLSv1.2
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384
Accept: application/json
emailBlurb=TesttextTesttextTesttextTesttextTesttext&templateRoles=%5BLjava.lang.Object;@3449f174&templateId=7078020e-49a0-42c6-b77d-368211d4a666&emailSubject=Please+sign+stuff&status=sent
400 BadRequest
Content-Type: application/json; charset=utf-8
{
"errorCode": "INVALID_REQUEST_BODY",
"message": "The request body is missing or improperly formatted. Unexpected character encountered while parsing value: e. Path '', line 0, position 0."
}
【问题讨论】:
标签: google-apps-script docusignapi google-docs-api google-sheets-api