Consider this code snippet from my answer to rao's question:
String requestUrl = '/services/data/v26.0/sobjects/User/describe';
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + requestUrl);
req.setMethod('GET');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
HTTPResponse res = http.send(req);
String output = res.getBody();
System.debug(output);
Works like a charm (provided you've added the instance to "Remote Site Settings" of course).
Now try with standard Salesforce page, for example
String requestUrl = '/001/o'; // or '/home/home.jsp' or anything else
And you get back this weird "placeholder" regardless which page you'll call.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<script>
var escapedHash = '';
var url = 'https://test.salesforce.com/?ec=302&startURL=%2F001%2Fo';
if (window.location.hash) {
escapedHash = '%23' + window.location.hash.slice(1);
}
if (window.location.replace){
window.location.replace(url + escapedHash);
} else {;
window.location.href = url + escapedHash;
}
</script>
</head>
</html>
Any idea what to do to get to the actual page?
Pass some undocumented header? Go through the frontdoor.jsp like suggested on SO? Or maybe I should expose PageReference.getContent()
as a REST service :D