You need to sign in to do that
Don't have an account?
Pavan Sonare
unknown method error in visualforce page
I am getting an unknown method error for the below integration code.
Below is the class.
here is vfpage code
Below is the class.
public class NumverifyApi { public integer phone {get;set;} public string code {get;set;} public boolean numvalid {get;set;} public string countryCode {get;set;} public string countryName {get;set;} public static void verifyNumber(integer phone, string code){ http http = new http(); HttpRequest request = new httpRequest(); request.setEndpoint('callout:Numverify?access_key=40e138077f26690623d13e0c5b6ad384&number='+code+Phone); request.setMethod('GET'); httpResponse response = http.send(request); system.debug(response.getStatusCode()); if(response.getStatusCode()==200){ map<string, Object> responseinReturn=(map<string,Object>)Json.deserializeUntyped(response.getBody()); boolean numvalid = (boolean)responseinReturn.get('valid'); string countryCode = (string)responseinReturn.get('country_code'); string countryName = (string)responseinReturn.get('country_name'); system.debug(numvalid); system.debug(countryCode); system.debug(countryName); } } }
here is vfpage code
<apex:page controller="NumverifyApi"> <apex:form id="rs"> <apex:pageBlock title="Input Phone Details"> <apex:pageBlockButtons location="Bottom"> <apex:commandButton value="Get Details" reRender="rs" action="{!verifyNumber}"/> </apex:pageBlockButtons> Phone : <apex:inputText required="true" value="{!phone}"/> <br/><br/> Coutnry Code : <apex:inputText required="true" value="{!code}"/> <br/><br/> </apex:pageBlock> <apex:pageblock title="Phone Number Details"> Is Phone number Valid? = {!numvalid}<br/><br/> Country code of the phone number = {!countryCode}<br/><br/> country of the Phone number = {!countryName} </apex:pageblock> </apex:form> </apex:page>
The error you're encountering is likely due to the fact that the method verifyNumber in your Visualforce page is not matching the method signature in your Apex class.
To resolve this issue, you need to update your Visualforce page to pass the required parameters when invoking the verifyNumber method. In the apex:commandButton tag, you need to include the parameters {!phone} and {!code} as arguments for the verifyNumber method. This will pass the values from the input fields to the method when the button is clicked.
If this helps , please mark this as Best Answer.
Thank you.