POST Method Examples

The following method creates a customer in response to a POST request in which the data for the customer is provided as primitive type parameters.

postCustomer(pName: String; pAddress: String);
vars
    customer: Customer;
begin
    beginTransaction;
    create customer;
    // Properties are set from the primitive parameters
    customer.name := pName;
    customer.address := pAddress;
    customer.myRoot := app.myRoot;
    commitTransaction;
end;

The following method creates a customer in response to a POST request in which the data for the customer is provided in the request body as an object in XML or JSON format.

postCustomer(pCust: Customer);
// pCust is a transient object created from
// XML or JSON before the method is invoked
vars
    customer: Customer;
begin
    beginTransaction;
    create customer;
    customer.name := pCust.name;
    customer.address := pCust.address;
    customer.myRoot := app.myRoot;
    commitTransaction;
end;

The following method creates a customer in response to a POST request in which the data for the customer is provided as parameters that are aggregated into a ParamListType entity.

postCustomer(params: ParamListType);
vars
    customer: Customer;
begin
    beginTransaction;
    create customer;
    // Properties are set from the parameters in the list
    customer.name := app.getParamListTypeEntry(1, params).String;
    customer.address := app.getParamListTypeEntry(2, params).String;
    customer.myRoot := app.myRoot;
    commitTransaction;
end;