I Created code, that do request from Google Maps to get geolocation. I have triggered flow, where I use Apex code to send my request. I need to hide my endpoint and Api-Key using Named Credentials.
It seems that it sending request with this part:
String geocodingUrl = 'callout:Geo1' + '/maps/api/geocode/json?address=' + encodedAddress;
But in logs I see that Request Denied, as I understand it mean that authorization was fall. For this part I have this code:
Http http = new Http();
HttpRequest httpRequest = new HttpRequest();
httpRequest.setEndpoint(request.geocodingUrl);
httpRequest.setMethod('GET');
httpRequest.setHeader('Authorization', 'Client-ID ' + '{!$Credential.Geo2.Key}');
HttpResponse httpResponse = http.send(httpRequest);
Can somebody help me please?