You need to sign in to do that
Don't have an account?
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.
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
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.
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!!
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.
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.
Facing the same problem....Any suggestion?
I am getting the same error. Did anyone find any solution for this? How can I test this in my sandbox?