Using the Web API

When you add Web API support to your Scaffolded project, the AB Suite MVC Scaffolder generates the following API Controller classes that can be used to expose RESTful services from the application over HTTP. The generated Controllers provide a base for further customization to include additional API calls if required.

The following table summarizes the API calls and gives an example of the call in each case:

TypeControllerMethodParametersExample and Description

GET

<SystemName>Ispec

For example, SampleIspec

GetConnect()

String userId

api/SampleIspec/Connect?userId=John

Connects to the host application. The user id is passed to the call, but is not used. It could be utilized as the station name.

GET

<SystemName>Ispec

GetStatus()

None

api/SampleIspec/Status

Retrieves the current status line information.

GET

<SystemName>Ispec

GetErrors()

Int num

api/SampleIspec/Errors?num=10

Returns up to ten errors from the current error list maintained by the application.

GET

<SystemName>Ispec

Get()

String ispec

api/SampleIspec/SampleIspec?ispec=PROD

Returns the data for the ispec named PROD.

GET

<SystemName>Ispec

GetMaint()

String ispec, String maint

api/SampleIspec
/maint?ispec
=PROD&maint=FIR

Retrieves data for the first record in the PROD ispec. Maint values can be FIR, NEX, BAC, LAS, DEL, and INQ.

POST

<SystemName>Ispec

PostTransmit()

Object ispec (FromBody) String TransmitIspec Bool context

api/SampleIspec
/Transmit?TransmitIspec
=PROD&context=true

This transmits the data sent in the request body as a JSON string.

The TransmitIspec parameter specifies the ispec to be used.

The context parameter determines whether to load the specified ispec before transmitting the data (that is, is the application state required or not).

POST

<SystemName>Ispec

GetList()

String listName

api/SampleList/list?listName
=ProductList

Retrieves a list called ProductList from the host application.

POST

<SystemName>Ispec

GetList()

String listName String listFormat String hc String dc

api/SampleList
/list?listName
=ProductList&listFormat
=%1%2&hc=1&dc=2

Retrieves a list called ProductList from the host application.

Uses the format parameter to display columns 1 and 2 in the list.

Specifies that the host column is column 1 and the display column is column 2.

The APIs exposed by the Web API interface are typically called through Ajax requests from the browser by using JavaScript. A typical scenario is where a SPA loads in the browser once and then makes calls to the Web API services to populate the parts of the application with data as required.

Additional custom APIs can be added to these Controllers as required.