0

This is my vf page

<apex:page controller="AccountRest">

    <apex:sectionHeader title="Accounts" subtitle="List View"/>
    <apex:pageBlock>

        <apex:pageBlockTable value="{!acc}" var="key">

            <apex:column>
                <apex:facet name="header">Account Name</apex:facet>
                <apex:outputLink value="/{!key.Id}">{!key.Name}</apex:outputLink>
            </apex:column>
            <apex:column value="{!key.AccountNumber}"/>
            <apex:column value="{!key.Type}"/>  

        </apex:pageBlockTable>

    </apex:pageBlock>

</apex:page>

this is my apex class

public with sharing class AccountRest {

    public list<account> acc{get{

        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://lokeshintegration-dev-ed.my.salesforce.com/services/data/46.0/query?q=SELECT+Id+,+Name+FROM+Account+10');
        req.setMethod('GET');

        //Get SessionId
        string autho = 'Bearer 00D2v00000275XI!AQkAQNll0I.b0ixHz5atKnmOyhUPpbQ3nQrhyS_1y7mrrKPk2rQEO9fHE7x1jFy4AHuvSRyrUSIjxal93JOZX9crk42ltZew';
        req.setHeader('Authorization', autho);

        //Get Response
        Http http = new Http();
        HTTPresponse res= http.send(req);
        string response = res.getBody();

        //Deserialize obtained json response
        string str = '['+ response.substring(response.indexOf('records":[')+10,response.indexof(']}')) +']';
        acc = (list<Account>)JSON.deserialize(str,list<Account>.class);

        return acc;    
    }set;}

}
4

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.