Friday, June 11, 2021

Salesforce Sample Rest API using Authentication

    

Salesforce Sample Rest API using Authentication:


   HTTPRequest r = new HTTPRequest(); 

    r.setEndpoint('https://test.com');

    Blob headerValue = Blob.valueOf('username' + ':' + 'password');

    String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);

    r.setHeader('Authorization', authorizationHeader);

    r.setHeader('Content-Type','text/xml;charset=UTF-8'); //application/json

    r.setMethod('GET'); //POST,PUT..

    r.setBody(strSetBody);

    HTTP h = new HTTP(); 

    HTTPResponse resp = h.send(r);

    system.debug('body===>'+resp.getBody());

    system.debug('getStatusCode==>'+resp.getStatusCode());

    system.debug('getStatus'+resp.getStatus());

Convert Encryption key to string (Decode the string)

Convert Encryption key to string or Decode the string or Covert MD5 hash to string :


Blob targetBlob = Blob.valueOf('ad89a9b94b5efd734e0c75a1480c20a4AD64439');

Blob hash = Crypto.generateDigest('MD5', targetBlob);

string hexDigest = EncodingUtil.convertToHex(hash);

system.debug('hexDigest==>'+hexDigest);

CSS Styling

Styling: 1. Inline Styling: < div style = "font-size: 2rem;font-weight: 400;" > Good Evening </ div > 2. Usi...