8

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.

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.

  1. 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?

  1. 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?

Thanks!

4
  • Are you getting this error in the response from the external system? Can you post the full stack trace from Apex Exception (or) full response?
    – Cloud Man
    Commented Jul 28, 2019 at 3:53
  • Hi @SFNinja. I'm getting this error : EXCEPTION_THROWN|[44]|System.CalloutException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 503 Service Unavailable" I Think that it came from some permission in the external service, But I gave them my URL for whitlist - but it this error is kep coming. URL : my-sandbox.cs108.my.salesforce.com I gave them only my-sandbox.
    – Salvation
    Commented Jul 31, 2019 at 11:38
  • Is the external system receiving the request sent by Salesforce? or may be it is getting blocked at firewall level or any application api gateway?
    – Cloud Man
    Commented Aug 1, 2019 at 15:42
  • Hi, I sorry for the delay. I don't think they get the request - because the response should have some value if it was. From postman it works perfectly.
    – Salvation
    Commented Aug 27, 2019 at 9:18

1 Answer 1

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

This URL looks like the one accessible only within company's network.

Ideally, your integration endpoint should be something which is accessible over internet since Salesforce integration calls are over internet.

1
  • Hi Ninja, you right. The other System First told me it assessable from any network and that why I insisted... Probably talked to the wrong people there. Thanks for your answer and sorry for the delay.
    – Salvation
    Commented Nov 14, 2019 at 10:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .