You need to sign in to do that
Don't have an account?
Dr. Thomas Miller
Secret Secure Storage - Named Credentials
The Secret Secure Storage - Named Credentials code that you are asked to inject into APEX is incorrect. Rather than
public string getOpenPortal() { HttpRequest req = new HttpRequest(); req.setEndpoint('callout:MagicPortal'); req.setMethod('GET'); Http http = new Http(); HTTPResponse res = http.send(req); return res.getBody(); }
it should be
public void openPortal() { HttpRequest req = new HttpRequest(); req.setEndpoint('callout:MagicPortal'); req.setMethod('GET'); Http http = new Http(); HTTPResponse res = http.send(req); portalStatus = res.getBody() ; }
I.e. do not return the body but put it into portalStatus.
public string getOpenPortal() { HttpRequest req = new HttpRequest(); req.setEndpoint('callout:MagicPortal'); req.setMethod('GET'); Http http = new Http(); HTTPResponse res = http.send(req); return res.getBody(); }
it should be
public void openPortal() { HttpRequest req = new HttpRequest(); req.setEndpoint('callout:MagicPortal'); req.setMethod('GET'); Http http = new Http(); HTTPResponse res = http.send(req); portalStatus = res.getBody() ; }
I.e. do not return the body but put it into portalStatus.