[SalesForce] Unable to tunnel through proxy. Proxy returns “HTTP/1.1 503 Service Unavailable”

I'm perfoming a HTTP GET callout to an external cURL connected through proxy, using Postman i get the response.
However, while making callout from Salesforce, it gives the following error:

System.CalloutException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 503 Service Unavailable"

I have whitelisted the Salesforce IP addresses in the external system and added the endpoint URL in remote site settings.

Here is my code:

Http http = new Http();
HttpRequest request = new HttpRequest();
String endpoint = 'https://username:password@mycURL';
request.setEndpoint(endpoint);
request.setMethod('GET');
HttpResponse response = http.send(request);

Am I missing something else? What could be the issue?

Thanks in advance

Best Answer

I don't believe that syntax is supported. Instead, you could use Basic authentication:

Http http = new Http();
HttpRequest request = new HttpRequest();
String endpoint = 'https://mycURL';
request.setEndpoint(endpoint);
request.setMethod('GET');
request.setHeader(
  'Authorization',
  'Basic '+EncodingUtil.base64Encode(Blob.valueOf('username:password'))
);
HttpResponse response = http.send(request);
Related Topic