You need to sign in to do that
Don't have an account?
AkiraDio
obj.Account.FirstName + ' ' + obj.Account.LastName + '\\n\\n' +
'Reservation Number ' + obj.co_coname__c + '.\\n\\n' +
'Your booking has now been confirmed.\\n\\n Please note: All hire bookings are subject to our hire terms and conditions which can be read here:\\n\\n' + obj.co_legal__c +
'\\n\\n On completion of your hire, post hire charges may apply - a Post Hire Charges Schedule is available to read here:\\n\\n' + obj.co_surcharges__c +
'\\n\\n Please review your booking details and complete the Cardholder Authorisation Form using the Docusign link below.\\n\\n By using Docusign, you can electronically sign and complete this document.\\n\\n (After you complete the form, all parties will receive a final PDF copy by email)\\n\\n';
String Body = '{\n \"emailSubject\": \"' + 'Booking Details ' + obj.Name + '",\n \"emailBlurb\": \"'+ MailBody +'\",\n \"templateId\": \"49131602-40EB-4548-AC8E-DE16DC9BE450\",\n \"templateRoles\": [\n {\n \"roleName\": \"Signer 1\",\n \"name\": \"'+ obj.Account.FirstName + ' ' + obj.Account.LastName +'\",\n \"email\": \"'+ obj.Hirer_Email__c +'\"\n }\n ],\n \"status\": \"sent\"\n}';
HttpRequest req = new HttpRequest();
req.setEndpoint('https://demo.docusign.net/restapi/v2/accounts/279584/envelopes');
req.setMethod('POST');
String authenticateStr = '{\"Username\":\"soloho@rogers.com\",\"Password\":\"docu777\",\"IntegratorKey\":\"WEBS-3d5dc187-4870-4a52-9276-3458da82699b\"}';
req.setHeader('X-DocuSign-Authentication', authenticateStr);
req.setHeader('Content-Type', 'application/json');
req.setHeader('Content-Length', String.valueOf(Body.length()));
req.setHeader('Accept', 'application/json');
Http http = new Http();
HTTPResponse res = http.send(req);
Result = res.getBody();
Call http request in a trigger
Hello!
I need to make a HTTP request to trigger.
But SFDC disallowed it.
How can I get out of this situation?
My code:
String MailBody = obj.co_coname__c + '\\n\\n' + obj.CreatedDate + '\\n' + ' FAO ' +obj.Account.FirstName + ' ' + obj.Account.LastName + '\\n\\n' +
'Reservation Number ' + obj.co_coname__c + '.\\n\\n' +
'Your booking has now been confirmed.\\n\\n Please note: All hire bookings are subject to our hire terms and conditions which can be read here:\\n\\n' + obj.co_legal__c +
'\\n\\n On completion of your hire, post hire charges may apply - a Post Hire Charges Schedule is available to read here:\\n\\n' + obj.co_surcharges__c +
'\\n\\n Please review your booking details and complete the Cardholder Authorisation Form using the Docusign link below.\\n\\n By using Docusign, you can electronically sign and complete this document.\\n\\n (After you complete the form, all parties will receive a final PDF copy by email)\\n\\n';
String Body = '{\n \"emailSubject\": \"' + 'Booking Details ' + obj.Name + '",\n \"emailBlurb\": \"'+ MailBody +'\",\n \"templateId\": \"49131602-40EB-4548-AC8E-DE16DC9BE450\",\n \"templateRoles\": [\n {\n \"roleName\": \"Signer 1\",\n \"name\": \"'+ obj.Account.FirstName + ' ' + obj.Account.LastName +'\",\n \"email\": \"'+ obj.Hirer_Email__c +'\"\n }\n ],\n \"status\": \"sent\"\n}';
HttpRequest req = new HttpRequest();
req.setEndpoint('https://demo.docusign.net/restapi/v2/accounts/279584/envelopes');
req.setMethod('POST');
String authenticateStr = '{\"Username\":\"soloho@rogers.com\",\"Password\":\"docu777\",\"IntegratorKey\":\"WEBS-3d5dc187-4870-4a52-9276-3458da82699b\"}';
req.setHeader('X-DocuSign-Authentication', authenticateStr);
req.setHeader('Content-Type', 'application/json');
req.setHeader('Content-Length', String.valueOf(Body.length()));
req.setHeader('Accept', 'application/json');
Http http = new Http();
HTTPResponse res = http.send(req);
Result = res.getBody();
This I can't really help you with too much. This relates to the fact your callout is timing out.
Try setting the request.setTimeout(60 * 1000) to increase the timeout limit to a minute or 120 * 1000 for two minutes. This may not solve the problem though...
All Answers
Unfortunately did not help (
You can't invoke an HTTP Callout straight from a trigger, you have to call a @future method to handle that for you. The future method also needs to be marked as callout=true... like so:
First error: Read timed out
This I can't really help you with too much. This relates to the fact your callout is timing out.
Try setting the request.setTimeout(60 * 1000) to increase the timeout limit to a minute or 120 * 1000 for two minutes. This may not solve the problem though...