Guest User

Untitled

a guest
May 30th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public class ProcessHandlerShowAccounts
  2. {
  3. public class AccountParameter
  4. {
  5. @InvocableVariable(required=true)
  6. public Id accountId;
  7. @InvocableVariable(required=true)
  8. public String name;
  9. }
  10. @InvocableMethod(label='handle' description='Send the Accounts variables passed from Process Builder to the webservice')
  11. public static void handle(AccountParameter [] accountParameters)
  12. {
  13. webServiceCallOut(accountParameters[0].accountId,accountParameters[0].name);
  14.  
  15. }
  16. public static void webServiceCallOut(ID n, String a){
  17. Http http = new Http();
  18. HttpRequest req = new HttpRequest();
  19. req.setEndpoint('https://Accounts'
  20. +'?sfdcid='+n+'?operation='+a);
  21.  
  22. String username = 'nameishi';
  23. String password ='123';
  24. Blob headerValue = Blob.valueOf(username + ':' + password);
  25. String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
  26. req.setHeader('Authorization', authorizationHeader);
  27.  
  28. //Create a new Http object to send the request object
  29. //a response object is generated as a result
  30. HTTPResponse res = http.send(req);
  31. System.debug(res.getBody());
  32. }
  33. }
Add Comment
Please, Sign In to add comment