I added the following VF page

<apex:page standardController="Account" extensions="createaccount" title="Test">
    <apex:outputText value="{makePostCallout}"/>

this is my apex class

public class createaccount {
    public static HttpResponse makePostCallout() {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setHeader('Content-Type', 'application/json;charset=UTF-8');
        // Set the body as a JSON object
        request.setBody('{{"system_id": "xyz"}}');
        HttpResponse response = http.send(request);
        // Parse the JSON response
        if (response.getStatusCode() != 201) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
            } else {
        return response;

in the developer console, I get the error

unknown constructor

Also When I go to create a custom button in Account object, I do not see this appearing in the drop-down list

2 Answers 2


With all changes suggested by sebastian(except outputtext to button), you need to have a constructor with standardcontroller, then only you'll be able to see VF button while creating button on object.

Like below -

public createaccount(ApexPages.StandardController stdController) {
  • 1
    I did not realize this was a standard controller. Good catch. Jul 16, 2020 at 3:36

apex:outputText is not for buttons, it is for text.

Use apex:commandButton for a button

Also, This is visualforce, not LWC. You must use the "curly-bang" method.

Instead of {makePostCallout}, write {!makePostCallout}

So, in summary, your code should read

<apex:page standardController="Account" extensions="createaccount" title="Test">
    <apex:commandButton value="{!makePostCallout}"/>
  • He is creating a button in configuration level(not on VF page)
    – Ysr Shk
    Jul 16, 2020 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.