我想使用Google表單中的信息(提交後)使用Docusign API從模板發送信封。如何在Docusign中使用Google表單/文檔中的信息,反之亦然?
信封完成後,我想發送一份不同的Google表單和一份Google文檔給同一個人。另外,我想在完成步驟後發送一些電子郵件。
我曾看過使用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": "[email protected]"
},
{
"roleName": "role3",
"name": "Joe Smith",
"email": "[email protected]"
}
],
"status": "sent"
}
var options =
{
"method" : "post",
"header":
{
"X-DocuSign-Authentication": "{\"Username\":\<username>\",\"Password\":\"<passwork>\",\"IntegratorKey\":\"<integratorkey>\"}"
},
"payload" : payload
};
UrlFetchApp.fetch(url, options);
}
更新:我改變header
到headers
,但現在我得到一個不同的錯誤。埃爾金,正如你所建議我登錄請求。以下是錯誤消息。似乎內容類型有問題。
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."
}
UPDATE:設置內容類型後,我得到了身體的格式不正確的錯誤。見下面
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 App腳本執行此操作嗎? –
嗨@Ergin,我剛剛發佈了一個更新。你能看看嗎? –
錯誤消息告訴你它無法在請求中找到您的Integrator密鑰,我會檢查並確保您的auth頭已正確連接,假設您傳遞的是有效密鑰。我看到你已經添加了一個'header'節點來添加標題,通常這應該是複數的'headers'。嘗試改變,如果不起作用,那麼你應該在你的帳戶中啓用請求記錄並運行跟蹤,以便檢查傳入的請求。 – Ergin