Skip to main content
Itai Russo (Malam) a posé une question dans #Integration
I'm trying to make an HTTP Request to other System.

They provided the endpoint URL which contains a Port number.

https://Test.com:50001/RESTAP/BGN/PRDV/CREATE

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.

When I make the request from Postman - I get the response as expected.

My code is : 

    Http httpProtocol = new Http();

            HttpRequest request = new HttpRequest();

            String url = 'https://Test.com:50001/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);

Note: The userName and Password will be filled from Custom setting.

I tried with and without the proxy header, I tried to turn the BASIC auth to Basic and many other little changes that didn't work.

I'm still getting this Error.

How can I know if it not blocked by Firewall? 

Any help or Idea to solve this issue

Thanks!
10 réponses
  1. 21 sept. 2020, 14:35
    Hi Itru and John Wheeler,

    salesforce IP addresses and your local IP addresses are two different addresses.

    postman uses you PC's public IP addresses but while making callout from salesforce you need to whitelist salesforce instance IP addresses.

    refer to this link Salesforce IP Addresses and Domains to Allow (https://help.salesforce.com/articleView?id=000321501&type=1&mode=1)
0/9000