2

I am stuck in to one strange problem. I am sending http request as below. The below request giving me perfect result when i m calling it from developer console, but for some reasons it is not working when called from vf page.

String requestUrl = '/setup/org/orgstorageusage.jsp?id='+UserInfo.getOrganizationId();
    Http http = new Http();
    HttpRequest req = new HttpRequest();        
    req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm().replace('https://c.','https://').replace('visual.force','salesforce') + requestUrl);        
    req.setMethod('GET');
    req.setHeader('Cookie','sid='+UserInfo.getSessionId());         
    HTTPResponse res = http.send(req);    
    string response = res.getBody();

Why it is not working when i call it from vf page?

I am getting below response in vf page case.

<!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> 
        if (this.SfdcApp && this.SfdcApp.projectOneNavigator) {
            SfdcApp.projectOneNavigator.handleRedirect(
              'https://login.salesforce.com/?ec=302&startURL=%2Fsetup%2Forg%2Forgstorageusage.jsp%3Fid%3D00D90000000xhQQEAY'); 
        } 
        else if (window.location.replace){
            window.location.replace(
             'https://login.salesforce.com/?ec=302&startURL=%2Fsetup%2Forg%2Forgstorageusage.jsp%3Fid%3D00D90000000xhQQEAY'); 
        } 
        else {
            ; window.location.href ='https://login.salesforce.com/?ec=302&startURL=%2Fsetup%2Forg%2Forgstorageusage.jsp%3Fid%3D00D90000000xhQQEAY'; } 
      </script> 
     </head> 
    </html> <!-- ................................................................................................... ................................................................................................... ................................................................................................... ................................................................................................... -->

Please help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.