I'm successfully calling the GetRestID method in this controller on my VisualForce Page and see the correct response from the getParameters() method from my SOQL query. The problem is trying to pass 'RestID' to my GET method. I believe the callout is happening before getParameters() returns the ID value of the current Account page.

What is the correct way to pass the active Account ID to my GET method?


public with sharing class extensionTest {

    private final Account acct;
    public String restID;
    public RSAPI.responseResource ConsoleWrapperList {get; set;}

    public extensionTest(ApexPages.StandardController controller) {

        this.acct = (Account)controller.getRecord();


    public String getGetRestID (){

    restID = [Select someID from account where id = :System.currentPagereference().getParameters().get('Id')].someID;

    return restID;


public wrapper.responseResource getperformCallout(){

HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();

Http http = new Http();
req.setEndpoint('https://blahblah/' + getGetRestID());

res = http.send(req);

if(res.getStatusCode() == 200 && res.getBody() != null){

ConsoleWrapperList = (wrapper.responseResource)json.deserialize(res.getBody(),wrapper.responseResource.class); 


return ConsoleWrapperList;



Apex Page:

<apex:page standardController="Account" extensions="extensionTest">
{!GetRestID} //The value to pass to GET method
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!performCallout}" var="wrap">
<apex:column value="{!wrap.someId}"/>
<apex:column value="{!wrap.someName}"/>
<apex:column value="{!wrap.someAmount}"/>
  • Page Parameters will be available to the controller's constructor and hence all controller methods will have access to them. How are you setting the page parameter - as part of the URL string for the VF page?
    – cropredy
    Nov 10, 2015 at 1:59
  • What do you see if you do System.debug(getGetRestID()) in getperformCallout()? Also, what are you actually seeing? An error? The Debug log should give you a lot of info about the callout - the URL it's trying to reach, the response etc.
    – metadaddy
    Nov 10, 2015 at 5:01
  • I've exhausted my searches and haven't found anything. Does anyone know of a link to an example of someone using a custom VF page in a page layout using an ID to pass to a REST call to retrieve data from a Locally hosted API? Nov 10, 2015 at 21:52

1 Answer 1


To anyone looking at this post, I solved my issue a different way.

The problem was that I was trying to pass the getParameters() id to my REST call on page load. getparameters() doesn't return in time without some Javascript manipulation such as setTimeout(). Instead, I made the user press a commandButton to make the callout. That way, getParameters() has the id to pass into the controllers method at the time of execution. Then appended the id to the end of the url.

Hope this makes sense to someone reading this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .