Test Credentials in the Target Org

Now that external credential access tokens are populated, use the named credential in a callout in your sandbox or testing org to verify that it works as expected.

Be careful not to test credentials in your production environment.

Warning

In this Apex code, a named credential and an appended path specify the callout’s endpoint. The referenced named credential specifies the endpoint URL, and the external credential connected to the named credential specifies authentication settings.

1HttpRequest req = new HttpRequest();
2req.setEndpoint('callout:My_Named_Credential/some_path');
3req.setMethod('GET');
4Http http = new Http();
5HTTPResponse res = http.send(req);
6System.debug(res.getBody());