Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger LeadCallout on Lead (after insert) {
- For (Lead l: Trigger.new){
- PostLeadtoBP.makePostLeadtoBP(l.Id, l.Phone);
- }
- public class PostLeadtoBP {
- public static void makePostLeadtoBP(String leadId, String phoneNo){
- Http http = new Http();
- HttpRequest req = new HttpRequest();
- long unixTime = System.currentTimeMillis() / 1000L;
- HttpResponse res = new HttpResponse();
- req.setEndpoint('/clientweb/api/v1/chats?tenantUrl=sprout.brightpattern.com×tamp='+unixTime);
- req.setMethod('POST');
- // Set Header for the Authorization
- req.setHeader('Content-Type', 'application/json;charset=UTF-8');
- req.setHeader('Authorization', '********************* appId="*********************", clientId="WebChat"' );
- // Set the body as a JSON object
- req.setBody(',parameters: {LeadID='+EncodingUtil.urlEncode(leadId,'UTF-8')+'phone='+EncodingUtil.urlEncode(phoneNo,'UTF-8') );
- req.setCompressed(true); // otherwise we hit a limit of 32000
- try {
- res = http.send(req);
- } catch(System.CalloutException e) {
- System.debug('Callout error: '+ e);
- System.debug(res.toString());
- }
- }
Add Comment
Please, Sign In to add comment