...
Generate named credentials with no authentication.
put there URL of the URL you want to call
Code Block https://e2e.pricefx.eu/pricefx/seeddata/formulamanager.executeformula/SalesforcePackage_getPrice
Write the Apex Code that will authorize with JWT Token
Code Block language java Auth.JWT jwt = new Auth.JWT(); jwt.setSub('topon'); //username of the pricefx user jwt.setAud('e2e'); //cluster name jwt.setIss('salesforceScratch'); //name of the external configuration Map<String, Object> claims = new Map<String, Object>(); claims.put('partition', 'seeddata'); //partition name jwt.setAdditionalClaims(claims); Auth.JWS jws = new Auth.JWS(jwt, 'pricefx_jwt_2048'); String token = jws.getCompactSerialization(); System.debug('------------- > : ' + token); HttpRequest req = new HttpRequest(); req.setEndpoint('callout:pfx_getPriceNoAuth'); req.setMethod('POST'); Http http = new Http(); req.setHeader('Authorization', 'BEARER salesforceScratch;' + token); req.setTimeout(120000); req.setBody('{"data": {"SFProduct": "Mercedes"}}'); HTTPResponse res = http.send(req); System.Debug('#### response:getBody: ' + res.getBody()); System.Debug('#### response:getStatusCode ' + res.getStatusCode()); System.Debug('#### response:getStatus ' + res.getStatus()); System.Debug('#### response:getStatusCode ' + res.getHeaderKeys()); //System.debug(res.getBody()); if (res.getStatusCode() == 200) { return res.getBody(); }
Call the APEX code and see the debug in the Salesforce Develop Console
You can validate JWT token
Check this other documentation https://ambassadorpatryk.com/2020/07/secure-calls-from-salesforce-to-mulesoft-with-jwt/