Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public with sharing class Util{
- @future (callout=true)
- public static void callWebservice(SET<Id> cont){
- List<Contact> contacts = [SELECT Id, LastName, FirstName FROM Contact WHERE Id = :cont];
- String jsonOrders = JSON.serialize(contacts);
- // debugging call, which you can check in debug logs
- System.debug('jsonOrders: ' + jsonOrders);
- // create an HTTPrequest object
- HttpRequest req = new HttpRequest();
- // set up the HTTP request with a method, endpoint, header, and body
- req.setMethod('POST');
- req.setEndpoint('http://xyz.com/mastercopytest/salesforce/salesforce_cron.php');
- req.setHeader('Content-Type', 'application/json');
- req.setBody(jsonOrders);
- // create a new HTTP object
- Http http = new Http();
- System.debug('Request Data '+ req);
- // create a new HTTP response for receiving the remote response
- HTTPResponse res = http.send(req);
- // debugging call, which you can check in debug logs
- System.debug('Fulfillment service returned '+ res.getBody());
- System.debug('getStatusCode '+ res.getStatusCode());
- // If status code != 200, write debugging information, done
- if (res.getStatusCode() != 200) {
- System.debug('Error from ' + req.getEndpoint() + ' : ' + res.getStatusCode() + ' ' + res.getStatus());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement