I have commandbutton which sends post request to external webservice. But when I click button it re-renders same page without sending request
Visualforce code:
<apex:inputText label="key" value="{! key}"/>
<apex:commandButton action="{! sendActivationKey}" immediate="true" image="{! $Resource.authBtn }" style="border:none;background:none;padding:0px;vertical-align:top;">
<apex:param name="akey" assignTo="{!akey}" value="{!key}"/>
</apex:commandbutton>
Apex code:
public static void sendActivationKey() {
String akey = System.currentPagereference().getParameters().get('akey');
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setMethod('POST'); // Method Type
req.setEndpoint('http://sfdc.datadoctorit.com/authenticate'); // Server Url
req.setHeader('Content-Type', 'application/x-www-form-urlencoded'); // Content Type
req.setBody('key=' + akey); // Request Parameters
res = http.send(req);
}
I don't understand where is the problem