Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HttpRequest req = new HttpRequest();
- req.setMethod('POST');
- req.setEndpoint('https://ZXXXXXXXX/api/ZXXXXXXXX');
- String username = 'ZXXXXXXXX';
- String password = 'XXXXXXXXXXXXXXX';
- Blob headerValue = Blob.valueOf(username + ':' + password);
- String authorizationHeader = 'Basic ' +
- EncodingUtil.base64Encode(headerValue);
- req.setHeader('Authorization', authorizationHeader);
- req.setHeader('Content-Type', 'application/json');
- req.setBody(JSON.serialize(lstOfObjectIWantToSend));
- System.debug('json serialized object:
- '+JSON.serialize(lstOfObjectIWantToSend));
- HttpResponse res = new Http().send(req);
- System.debug('Response from Server in Salesforce: '+res);
Add Comment
Please, Sign In to add comment