I am new to using Named Credentials. I created a Named Credential with following details: Identity Type: Name Credential Authentication Protocol: Password Authentication and added username and password. Generate HTTP headers as true
I am using below code to access my named credential: (API_Login_Information is the name of my named credential)
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:API_Login_Information');
req.setMethod('GET');
HttpResponse res = h.send(req);
However, I am getting error when doing callout as the api documentation (to which I am trying to connect) says username and password are mandatory when calling the service:
Ex: Lets say service name is https://www.google.com
, I need to send username and password in url as below:
https://www.google.com/xml.php?_[action]=auth&login=***username****&password=****password*****
Can I achieve above requirement using named credential (when I try with out using named credential but using custom setting it is working from anonymous window and yes, they need the password in URL)
P.S: Referred to this question where sfdcfox answered we cannot use merge fields in url then is there any other way to achieve this.