+ Start a Discussion
Richie DRichie D 

Pagereference call outs not working

Hi Developers,

 

According the the documentation (and my memory) the following should work:-

 

PageReference ref = new PageReference('http://www.google.com');
Blob b = ref.GetContent();

 Why are we getting the following error upon execution of the getContent() method? 

 

System.VisualforceException: java.net.NoRouteToHostException: No route to host

 

This error (seems to )occur for all urls other than Salesforce! (http://www.salesforce.com, https://cs7.salesforce.com are ok).

 

Thanks for any help.

Rich.

 

Abhishek_PareekAbhishek_Pareek

Putting an entry (for "http://www.google.com" here and for any external site you want to hit ),in "Remote Site Settings" under "Security Controls" may resolve the issue. Hope this helps.

Richie DRichie D

Have already done this and doesn't help any.

 

Thanks for your suggestion - other users may find it useful.

 

Cheers,

Rich.

Jia HuJia Hu
I am facing the same issue, does anyone have a solution now?
suziee Qsuziee Q

Hi Salesforce,

 

We have same issues actually.

 

In sandbox, that pagereference does not work.

 

But in Developer instances, that works fine. We have tried 2 developer instances. Both work. 

Jia HuJia Hu
Would you please share your code?
suziee Qsuziee Q

Hi Jia,

 

If you execute those code lines below in developer console straight way without controller, any instance can do that successfully. 

If you put them in a controller and run that controller, all fail except developer instances. 


I think that is salesforce server side bug related to java frame expecially for call out, because if you fetch a document or an attachment in SF using that way, it will work.

-------------------------------------------------------------------------------

String thestr = 'http://www.google.com';
PageReference page=  new PageReference(thestr);
Blob  p = page.getContent();

Jia HuJia Hu
If you call the Controller by a VF page, it will be fine.
Through Execute Anonymous directly, you may get errors.
suziee Qsuziee Q

unfortunately, I use VF page. but still same error

 

java.net.NoRouteToHostException: No route to host

Error is in expression '{!getgoogle}' in component apex:page in page s_download


An unexpected error has occurred. Your development organization has been notified.