I'm trying to make an HTTP Request to other System.
They provided the endpoint URL which contains a Port number.
When I'm trying to make the request I facing with this ERROR:
System.CalloutException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 503 Service Unavailable"
although I have added the URL in remote sites.
I saw some solutions about this Error (Mostly on a similar error : with "HTTP/1.0 404 Not Found") - like - ask the Other system to whiteList Salesforce IPs.
- There are many IPs to add to the WhiteList by the other System From here: https://help.salesforce.com/articleView?id=000321501&type=1&mode=1.
This is the best practice to add to White List by IP? If it will change (Delete, Add, Update) SF will notify me about that? Can I send them URL Instead?
How can I send the Port using Apex? this is my code :
Http httpProtocol = new Http(); HttpRequest request = new HttpRequest(); String url = 'https://Test.com/RESTAP/BGN/PRDV/CREATE'; String username2 = 'Name'; String password2 = 'Passowrd'; Blob headerValue = Blob.valueOf(username2 + ':' + password2); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); request.setEndpoint(url); request.setMethod('POST'); request.setHeader('Authorization', authorizationHeader); request.setTimeout(60000); request.setHeader('Content-Type','application/json'); request.setHeader('proxyPort','50001'); request.setHeader('proxyHost','PROXYHOST URL'); request.setHeader('proxySet','true'); HttpResponse response = httpProtocol.send(request);
I tried to send the port via HEADER like above and via change the URL to :
String URL = 'https://Test.com:50001/RESTAP/BGN/PRDV/CREATE';
But the error keeps coming.
Is there another thing I need to consider except ask the other System to add SF to the whiteList?