Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DocuSign {
- public void test(String email, String name){
- String accountID = 'ec57264a-5e70-****-8ee1-ed2578cd3bdf';
- String userName = 'f14763b1-***-**-8e89-ef7297adb9c0';
- String passWord = '22223';
- String integratorKey = 'EDRE-****-0f94-4e13-8b24-c7ebacb3464a';
- String templateID = '6d3eb7ad-77ee-eeee-a22b-efb4f578fc0b';
- String endPoint = 'https://demo.docusign.net/restapi/v2/accounts/'+accountID+'/envelopes';
- //Apex HTTP Method Initialization.
- HttpRequest req = new HttpRequest();
- req.setEndpoint(endPoint);
- req.setMethod('POST');
- String authorizationHeader = '<DocuSignCredentials><Username>'+userName+'</Username><Password>'+Password+'</Password><IntegratorKey>'+integratorKey+'</IntegratorKey></DocuSignCredentials>';
- req.setHeader('X-DocuSign-Authentication', authorizationHeader);
- req.setHeader('Accept','application/json');
- req.setHeader('Content-Length','162100');
- req.setHeader('Content-Type','application/json');
- req.setHeader('Content-Disposition','form-data');
- string b = '{'+
- '"emailSubject":"DocuSign Templates Envelope Demo",'+
- ' "emailBlurb": "demo is sending you this request for your electronic signature.nnPlease review and electronically sign by following the link below. ",'+
- '"status": "sent",' +
- '"compositeTemplates": ['+
- '{'+
- '"serverTemplates": ['+
- '{'+
- '"sequence": "1",'+
- ' "templateId": "'+templateID+'",'+
- '}'+
- '],'+
- '"inlineTemplates": ['+
- '{'+
- '"sequence": "1",'+
- '"recipients": {'+
- '"signers": ['+
- '{'+
- ' "signingGroupId": "3839076",'+
- '"name": "First Recipient",'+
- '"recipientId": "1",'+
- '"roleName": "RoleOne"'+
- '}'+
- ']'+
- '}'+
- '}'+
- ']'+
- '},'+
- '{'+
- '"serverTemplates": ['+
- '{'+
- '"sequence": "1",'+
- '"templateId": "'+templateID+'",'+
- '}'+
- '],'+
- '"inlineTemplates": ['+
- '{'+
- '"sequence": "1",'+
- '"recipients": {'+
- '"signers": ['+
- '{'+
- '"signingGroupId": "3839076",'+
- '"name": "First Recipient",'+
- '"recipientId": "1",'+
- '"roleName": "RoleOne"'+
- '}'+
- ']'+
- '}'+
- '}'+
- ']'+
- '}'+
- ']'+
- '}';
- req.setBody(json);
- Http http = new Http();
- HTTPResponse res;
- try{
- //Docusign Request Callout.
- res = http.send(req);
- system.debug('DocuSign Response'+ res.getBody());
- }
- catch(Exception e){
- SYSTEM.DEBUG('!!!!');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement