+ Start a Discussion

Unable to make REST call via Apex class.

Hi, I am requesting a service to the endpoint using REST call.

Now this endpoint url is in client network. We are accessing other URLs in client network within our application which works fine.

i have configured the endpoint under Remote Site settings and trying to send the request as POST method to the endpoint via Apex class. I am getting Service Unavailable response and the description of the body says 'Unable to determine IP address from host name'.

Since we this is just a HTTP URL , i tried creating a custom link and tried invoking the URL which works fine within the same app.

So I am not sure when I am able to access the endpoint URL via custom link within the app then why I am unable to access the same endpoint via Apex class?

Any suggestions would be highly appreciated.


It sounds like whatever URL you're trying to hit is only available on your network.  The custom link causes your own browser to go and make the HTTP request to your endpoint, while doing it from apex causes the salesforce servers to make the HTTP request.  Salesforce can't resolve your domain to an IP address, so that's why the call fails.


You need to make sure your endpoint is publicly available for an apex callout to work.