1. Create a named credential like below specifying any username. Make sure that you have checked "Allow Merge Fields in HTTP Header" and unchecked "Generate Authorization Header" options.
2. Specify the API key in your Apex code using {!$Credential.Password} merge field.
2. Specify the API key in your Apex code using {!$Credential.Password} merge field.
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:AnonAPI');
req.setHeader('APIKEY', '{!$Credential.Password}');
req.setMethod('GET');
HttpResponse res = new Http().send(req);
0 comments:
Post a Comment