+ Start a Discussion
Ramu SfdcRamu Sfdc 

call the api class from the visualforce page button

Hi All,
I am new to salesforce, whenever we click the result button will have to call the api class and automatically it will execute inside the logics of API class could any one please help me out 

Through the button will have to run the Api class i tried this below but its throwing an error urgent requirement, please help me out

<apex:page standerdController =''Applicationobj__c'' extension="extensincntrl">
    <apexcommondbutton action={!Runapi} value="result"/>

public with sharng class extensincntrl{

public PageReference Runapi(){
PageReference  P =new PageReference ('/apex/someclassnameFrom?id=' +currentRecordid);
return p;

Apiclass ap= new api class();
//return ap;
string returnvlue =ap.methodfromApiclass();
retutrn returnvlue ;

intigration (api)class
public with sharng class Apiclass {

public static httprequest   createhttp(httprequest   req, string uri){

//some logic of update the fields in the object



Thanks in advance.

Suraj Tripathi 47Suraj Tripathi 47
Hi Ramu,

I think the error should be in this line
<apex:page standerdController =''Applicationobj__c'' extension="extensincntrl">

in standerdController you have to mention only standard objects for custom objects use Controller only and still
if you getting errors so please mention your complete error so that I can help you.

If you find your Solution then mark this as the best answer. 

Thank you!

Suraj Tripathi