Guest User

Untitled

a guest
Mar 12th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. HttpRequest req = new HttpRequest();
  2. req.setMethod('POST');
  3.  
  4. req.setEndpoint('https://ZXXXXXXXX/api/ZXXXXXXXX');
  5. String username = 'ZXXXXXXXX';
  6. String password = 'XXXXXXXXXXXXXXX';
  7. Blob headerValue = Blob.valueOf(username + ':' + password);
  8. String authorizationHeader = 'Basic ' +
  9. EncodingUtil.base64Encode(headerValue);
  10. req.setHeader('Authorization', authorizationHeader);
  11. req.setHeader('Content-Type', 'application/json');
  12.  
  13. req.setBody(JSON.serialize(lstOfObjectIWantToSend));
  14.  
  15.  
  16. System.debug('json serialized object:
  17. '+JSON.serialize(lstOfObjectIWantToSend));
  18.  
  19. HttpResponse res = new Http().send(req);
  20.  
  21. System.debug('Response from Server in Salesforce: '+res);
Add Comment
Please, Sign In to add comment