I am trying to call an external webservice and display the data in a Visualforce Page.

First how do I pass a parameter to the external Web service?

This is what I have done so far:

  1. Created the remote site
  2. Created a wrapper class that has variables that will hold the data from the external data source
  3. Created a visualforce page
  4. Created Apex Class using http request and get methods.

But I do not want to return all the data from the source. I want to call the Visualforce Page from a link on the Account record.

How can I pass the Account Id to the Web service so to that it only return records related to that account?

My second question is what is the best option to get the Visualforce Page to open in a new tab not window?

Here is the Apex Class:

public class JDECalloutcontroller {
    public List<JDEwrapper> JDEWrapperList{get;set;}
    public List<JDEwrapper> getperformcallout(){

    JDEWrapperList = new List<JDEwrapper>();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();

    Http http = new Http();
    req.setEndpoint('http:// ***whatever the web service uri is***/api/addressbook/?Acctid=Id');

    res = http.send(req);

    if(res.getstatusCode() == 200 && res.getbody() != null){


    return JDEWrapperList;

Here is sample of my VF page

<apex:page controller="Calloutcontroller" title="JDE table" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!performcallout}" var="jde" width="100%">
                <apex:column headerValue="AddressBookNumber" value="
                <apex:column headerValue="Name" value="{!jde.Name}"/>

Can I use <apex:outputLink> and pass my parameter at the same time? For example: /apex/JDE_Call_Out?acctId={!Account.Id }

  • Are you on lightning? If you are not on lightning you could create a javascript button that adds a new tab that is pointing to the page you are using. You could create a class in salesforce for the response and parse the response into that class. Then you could add that to your visualforce page. – Dan Kowalski Jun 16 '17 at 20:28
  • Dan, thank you for the reply. We are not using lightning at this time but this will change sooner than later. Will you elaborate on your respoonse "Create a class in SF for the response..."? Will the JDECallOut controller not populate the data in the Wrapper that is used in the VF page? Thanks – Michael Jun 21 '17 at 13:38
  • The following Link should be able to give you an example of what I am referring to. This example goes through parsing a JSON response into a class. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… – Dan Kowalski Jun 21 '17 at 13:41

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.