Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public with sharing class AS_httpSyncToWordpress {
- @future (callout=true)
- public static void sendAPIRequestInsert(Set<Id> setAllId) {
- Contact[] allContact= [Select Id,FirstName,LastName,Email FROM Contact where ID IN :setAllId];
- HttpRequest req = new HttpRequest();
- HttpResponse res = new HttpResponse();
- Http http = new Http();
- String username = 'sampleusername';
- String password = 'samplepassword';
- Blob headerValue = Blob.valueOf(username + ':' + password);
- String authorizationHeader = 'BASIC ' +
- EncodingUtil.base64Encode(headerValue);
- req.setHeader('Authorization', authorizationHeader);
- // below is just a sample endpoint
- req.setEndpoint('https://mysampleEndpoint.com:8080/wp-json/myApi/v1/create_contact');
- req.setMethod('POST');
- // req.setHeader('Content-Length','2004');
- req.setHeader('Content-Type', 'application/json');
- req.setBody(JSON.serialize(allContact));
- // req.setCompressed(true); // otherwise we hit a limit of 32000
- System.debug('allContact : ' + allContact);
- System.debug('REQUEST : ' + req);
- try {
- res = http.send(req);
- System.debug('RESPONSE wew ' + res.getBody());
- } catch(System.CalloutException e) {
- System.debug('Callout error: '+ e);
- System.debug(res.toString());
- }
- }
- }
- System.HttpRequest retrying request in response to handshake failure: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement