function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
goabhigogoabhigo 

The requested URL could not be retrieved

Hi,

I am receiving the following error message while trying to make an HTTP request via Apex class. I have set the relevant site in 'Remote Site Setting'.

Here is the error message:
------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to retrieve the URL:
<A HREF="http://gateway.onewaysms.com.my:10001/bulktrx.aspx?">http://gateway.onewaysms.com.my:10001/bulktrx.aspx?</A>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Access Denied.
</STRONG>
<P>
Access control configuration prevents your request from
being allowed at this time. Please contact your service provider if
you feel this is incorrect.
</UL>
<P>Your cache administrator is <A HREF="mailto:support@salesforce.com">support@salesforce.com</A>.


<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Tue, 25 Jan 2011 08:54:48 GMT by proxy-sin.net.salesforce.com (squid)
</ADDRESS>
</BODY></HTML>

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


I have been trying to solve but no use. The URL works fine when I use it in Detail Button- it displays me the correct result. But when I use it in class it shows the above pasted error message.

 

The apex class is:

 

url='http://gateway.onewaysms.com.my:10001/bulktrx.aspx?mtid=1101210013461';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
HttpResponse res = h.send(req);
res.getBody();

System.debug(res.getBody()); ----> Here I get the above error message(highlighted in red).

 


Any suggestion will be highly helpful.

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

When you click a button that opens the URL, you are making the request from your browser (and hence your browser's IP address).  When you access it through apex code, the request comes from the Salesforce server (and hence one of the IP addresses associated with the datacenter).  If the resource is locked down to allow your location access, then the server request would be denied.

All Answers

bob_buzzardbob_buzzard

Is the resource that you are trying to access locked down in any way?  It may be that because the request comes from the salesforce servers it is being denied.

goabhigogoabhigo

But the same resource is accessible through button URL, then why not in code?

 

I am not sure whether salesforce is requesting some more resource!!

bob_buzzardbob_buzzard

When you click a button that opens the URL, you are making the request from your browser (and hence your browser's IP address).  When you access it through apex code, the request comes from the Salesforce server (and hence one of the IP addresses associated with the datacenter).  If the resource is locked down to allow your location access, then the server request would be denied.

This was selected as the best answer
goabhigogoabhigo

Thanks Bob. I appreciate the knowledge you shared. But according to me(as told by executive of the SMS gateway server) there is no restriction based on the location. So the request can be done from anywhere. But I am not an expert what exactly is going wrong.

BenoyBenoy

Facing the same problem....Any suggestion?

mysteriousauramysteriousaura
Hello,

I am getting the same error. Did anyone find any solution for this? How can I test this in my sandbox?
patricia wildpatricia wild
Access control Miami (http://dicsan.com/access_control/access-control-miami/) is one of the most crucial elements in the property management process. Without adequate access control, it becomes challenging to safeguard assets and property from unauthorized access and entry, unsecured public parking lots, unruly tenants, and unruly guests. The security needs of Miami residential communities and business properties are vast. Therefore it is advisable to contact a reputable company that offers comprehensive security systems at competitive rates and the best quality. For more details on access control Miami, contact a reputable security access control company today.