以下是一个示例代码,演示如何使用Adobe Sign和Salesforce合作,在发送签名后设置重定向URL:
// 创建Adobe Sign发送请求
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.na2.echosign.com/api/rest/v6/agreements');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
request.setHeader('Authorization', 'Bearer {access_token}');
// 设置请求体参数
String requestBody = '{ "fileInfos": [ { "libraryDocumentId": "{library_document_id}" } ], "recipients": { "signers": [ { "email": "{signer_email}", "name": "{signer_name}" } ] }, "options": { "redirectUrl": "{redirect_url}" } }';
request.setBody(requestBody);
// 发送请求并获取响应
HttpResponse response = new Http().send(request);
String responseBody = response.getBody();
// 处理响应
if(response.getStatusCode() == 201) {
// 解析响应体以获取agreementId
Map responseMap = (Map) JSON.deserializeUntyped(responseBody);
String agreementId = (String) responseMap.get('agreementId');
// 保存agreementId到Salesforce对象中
MySalesforceObject__c obj = new MySalesforceObject__c();
obj.AdobeSignAgreementId__c = agreementId;
// 设置其他字段值
// ...
insert obj;
// 重定向到指定URL
String redirectUrl = '{redirect_url}?agreementId=' + agreementId;
PageReference pageRef = new PageReference(redirectUrl);
pageRef.setRedirect(true);
return pageRef;
} else {
// 处理错误
// ...
}
在上面的代码中,你需要将以下内容替换为你自己的值:
{access_token}
: 你的Adobe Sign访问令牌。{library_document_id}
: 你要发送的Adobe Sign库文档的ID。{signer_email}
: 签署者的电子邮件地址。{signer_name}
: 签署者的姓名。{redirect_url}
: 签署后重定向的URL。请注意,此代码需要使用Salesforce Apex编程语言,并且假设你已经设置了适当的Adobe Sign和Salesforce集成。