I have a requirement to integrate Salesforce with external system, the Endpoint APIs are provided and i am using Named Credentials for making the callouts using Apex:
Below is the details for Authentication ENDPoint:
- URL : www.example.com/authenticate
- Method : POST
- Header : apiKey : "afdsfgfddkgk"
- Username : admin
- Password : admin
After authentication i have to make a call to the below Product Details URL to fetch the details
- URL : www.example.com/v1/pickup-requests
Note there is a slight difference in the path, my product details endpoint doesn't have authenticate in the path where as Named Credentials has.
When making the callout i am using the below Apex code:
HttpRequest req = new HttpRequest(); req.setEndpoint('callout:ApiCredentials/v1/pickup-requests'); req.setMethod('GET'); Http http = new Http(); HTTPResponse resp = http.send(req);
When i debug the log the Endpoint changes to www.example.com/authenticate/v1/pickup-requests.
Question : Is there a way to get rid of path /authenticate while making callouts.
Thanks in advance