Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. public with sharing class Util{
  2.  
  3. @future (callout=true)
  4. public static void callWebservice(SET<Id> cont){
  5.  
  6. List<Contact> contacts = [SELECT Id, LastName, FirstName FROM Contact WHERE Id = :cont];
  7.  
  8. String jsonOrders = JSON.serialize(contacts);
  9.  
  10. // debugging call, which you can check in debug logs
  11. System.debug('jsonOrders: ' + jsonOrders);
  12. // create an HTTPrequest object
  13.  
  14. HttpRequest req = new HttpRequest();
  15.  
  16. // set up the HTTP request with a method, endpoint, header, and body
  17. req.setMethod('POST');
  18. req.setEndpoint('http://xyz.com/mastercopytest/salesforce/salesforce_cron.php');
  19. req.setHeader('Content-Type', 'application/json');
  20.  
  21. req.setBody(jsonOrders);
  22. // create a new HTTP object
  23. Http http = new Http();
  24.  
  25. System.debug('Request Data '+ req);
  26.  
  27. // create a new HTTP response for receiving the remote response
  28. HTTPResponse res = http.send(req);
  29.  
  30. // debugging call, which you can check in debug logs
  31. System.debug('Fulfillment service returned '+ res.getBody());
  32.  
  33.  
  34. System.debug('getStatusCode '+ res.getStatusCode());
  35.  
  36. // If status code != 200, write debugging information, done
  37. if (res.getStatusCode() != 200) {
  38. System.debug('Error from ' + req.getEndpoint() + ' : ' + res.getStatusCode() + ' ' + res.getStatus());
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement