REST

Labels
AJAX(112) App Studio(7) Apple(1) Application Builder(245) Application Factory(207) ASP.NET(95) ASP.NET 3.5(45) ASP.NET Code Generator(72) ASP.NET Membership(28) Azure(18) Barcode(2) Barcodes(3) BLOB(18) Business Rules(1) Business Rules/Logic(140) BYOD(13) Caching(2) Calendar(5) Charts(29) Cloud(14) Cloud On Time(2) Cloud On Time for Windows 7(2) Code Generator(54) Collaboration(11) command line(1) Conflict Detection(1) Content Management System(12) COT Tools for Excel(26) CRUD(1) Custom Actions(1) Data Aquarium Framework(122) Data Sheet(9) Data Sources(22) Database Lookups(50) Deployment(22) Designer(177) Device(1) DotNetNuke(12) EASE(20) Email(6) Features(101) Firebird(1) Form Builder(14) Globalization and Localization(6) How To(1) Hypermedia(2) Inline Editing(1) Installation(5) JavaScript(20) Kiosk(1) Low Code(3) Mac(1) Many-To-Many(4) Maps(6) Master/Detail(36) Microservices(4) Mobile(63) Mode Builder(3) Model Builder(3) MySQL(10) Native Apps(5) News(18) OAuth(9) OAuth Scopes(1) OAuth2(13) Offline(20) Offline Apps(4) Offline Sync(5) Oracle(11) PKCE(2) Postgre SQL(1) PostgreSQL(2) PWA(2) QR codes(2) Rapid Application Development(5) Reading Pane(2) Release Notes(183) Reports(48) REST(29) RESTful(29) RESTful Workshop(15) RFID tags(1) SaaS(7) Security(81) SharePoint(12) SPA(6) SQL Anywhere(3) SQL Server(26) SSO(1) Stored Procedure(4) Teamwork(15) Tips and Tricks(87) Tools for Excel(2) Touch UI(93) Transactions(5) Tutorials(183) Universal Windows Platform(3) User Interface(338) Video Tutorial(37) Web 2.0(100) Web App Generator(101) Web Application Generator(607) Web Form Builder(40) Web.Config(9) Workflow(28)
Archive
Blog
REST
Tuesday, December 14, 2021PrintSubscribe
December / January 2022 Roadmap

We are happy to introduce the Level 3 REST API Engine, the new amazing feature of Code On Time apps. Automatic production of Progressive Web Apps and the barcode scanning with the device camera will follow shortly 

Level 3 REST API Engine

The work on our own content management system and numerous inquiries from customers have prompted us to build a new REST API Engine. It is built directly into the server-side framework and exemplifies an exceptional piece of technology. Your app converts into powerful middleware with just a few keystrokes. The API of the app evolves as you create new data models and customize your app with actions and views. The new engine classifies as the Level 3 REST API according to the Richardson Maturity Model

The hypermedia links are self-documenting the API. Developers can extend their own Code On Time app frontend with the help of the built-in RESTful interface. Alternatively the entire application can become the backend of a custom mobile or web client making HTTP requests to the REST API to read and write data.

Here is an example of an application resource with the hypermedia controls embedded in it. The singleton of a product has the hypermedia links for the SupplierID and CategoryID lookup fields. Links to “edit”, “replace”, “delete”, and execute a custom action “custom-action2” are also available with the corresponding HTTP methods.

This is the same data item presented in the editForm1 view of the Products controller. Change the form and the API will change automatically.


The inventory resource corresponding to the dashboard controller Inventory is presented next. It has Categories, Products, and Suppliers fields of the dataview type and an alternative dashboard2 view. 

This is how the Inventory dashboard looks like in the application when running in the development mode.


The standard frontend of your application provides the visual interpretation of its  REST API resources. Naturally you can use this frontend as the primary user interface for your application or create custom mobile or web apps using the technology of your choice.


The new REST API engine produces the responses in JSON, Yaml, and XML formats.


Future releases of the product will include a complete GraphQL runtime that will convert the queries and mutations into the internal REST API calls.

Barcode Scanning With Device Camera

Your apps will finally have an option to scan the barcodes and QR codes without relying on the external scanners. The powerful UI Automation and Kiosk UI already available to the app developers are getting a boost! The QR code icon on the toolbar activates the camera-based scanner powered by the Zxing (zebra crossing) library.  

The camera scanner icon is available when barcode support is enabled. Developers will also have an option to automatically activate the scanner when a particular form is displayed or a field is focused. The scanned barcodes and QR codes are placed in the barcode processing queue, which is also populated by the external scanners and readers.

The simple and powerful IfThisThenThat API allows creating complex rules that force the UI of the app to perform various actions in response to the contents of the barcode queue.

Automatic Production of PWA 

We are finally bringing a unified native experience to Android, Chrome OS, and Windows. Code On Time apps are getting built-in support for Progressive Web Apps technology. Users running your application in Microsoft Edge and Google Chrome will see a prompt to install the app. Installed applications will have no address bar and will behave just like any native application does.

We will continue to support the Cloud On Time universal client for Apple and Mac OS platforms. 

Last But Not Least

REST API engine provides the missing building block for the Content Hub, the new Content Management System (CMS) for Code On Time applications. The new CMS will infuse them with the community forum, help desk, blog, and documentation library. 

Our website will move to our own technology. The documentation library and community forum will become integrated into https://my.codeontime.com. New live design environment v9 integrates with the Content Hub to deliver the unmatched level of productivity when building applications with Code On Time. 


Friday, August 20, 2021PrintSubscribe
August/September 2021 Roadmap

We are very pleased to announce the host of new features that are becoming available in the next few weeks. 2-Factor Authentication, new REST API v2, and barcode scanning with the device camera, are just some of the features that are coming at the end of the summer.

2-Factor Authentication

The next release 8.9.23.0 will introduce 2-Factor Authentication that will be enabled by default in apps created with the Unlimited Edition of Code On Time.

End users will have an option to strengthen their username and password with the one-time verification codes that are delivered via email, text message, or “authenticator” apps such as Google Authenticator or Microsoft Authenticator.

User context menu provides a new option that helps the authenticated user to set up the 2-factor authentication. If the user has the “authenticator” app on their mobile device, then a simple scan of the QR code on the setup screen will configure that app to generate the verification codes to confirm to sign in.
 

 
Authenticator app does not have a physical connection to your application. The scan of the QR code during the setup allows the app to retrieve the secret stored in the user record.  The app generates a new verification code frequently. There is no need to remember the code. You will be able to sign in as long as you have access to your phone.

You will be required to enter the username and password.
 

 
The successful sign in will result in the request to enter the verification code if the 2-factor authentication was set up for the account previously. 
 

 
Another default option is to receive an email with the verification code that expires in a few minutes. Developers also have an option to instruct the app to send a text message or call the user with the verification code. 

If the correct time-based verification code is entered, then the user is signed in. Incorrect input of verification code will count as a failed login attempt with the eventual lockout of the user account.

“Authenticator App” is a very secure option since there is no communication with the 3rd party systems. The default “Email me at...” option can be disabled in the application if required.

Users can also enter the single use backup codes provided to the user during the setup process.

REST API v2 / App Middleware

We are pleased to announce the new REST API v2 available in the apps created with the Unlimited Edition. 

The server-side framework automatically responds to the requests to read and write data  by creating JSON or YAML based output. Hypertext Application Language links are automatically included in the responses to enable the API discovery.
 


The new REST API is the automatic reflection of your data controllers, lookups, and dataview fields. The root entry point of the API serves as the introspection end-point that helps to learn what’s possible.

API Keys and access tokens help authenticating the request. The new API can be used internally and also as a middleware for the projects that require database access. Developers can even enable the “middleware” mode when no user interface options are available and only the API requests are being handled. 

Camera-Based Barcode Scanning

Your apps will finally have an option to scan the barcodes and QR codes without relying on the external scanners. The powerful UI Automation and Kiosk UI already available to the app developers are getting a boost! The QR code icon on the toolbar activates the camera-based scanner powered by the Zxing (zebra crossing) library.  

The camera scanner icon is available when barcode support is enabled. Developers will also have an option to automatically activate the scanner when a particular form is displayed or a field is focused. The scanned barcodes and QR codes are placed in the barcode processing queue, which is also populated by the external scanners and readers.

The simple and powerful IfThisThenThat API allows creating complex rules that force the UI of the app to perform various actions in response to the contents of the barcode queue.

V9 and Integrated Community

We have made great progress in delivering the new browser-based development environment for your apps. The screenshots above show the live preview mode of upcoming v9. It will become the default mode for Code On Time developers and provide property grids and  toolbars with drag & drop configuration and point-and-click inspection of live apps.

The community forum is integrated into the new development environment and will allow discussing and documenting various features right from the property grid. The news feed will also be readily available along with the place to see the latest discussions, tickets, and blog posts.

Monday, September 18, 2017PrintSubscribe
Executing Requests with the Client API

All apps created with Code On Time app generator contain a single client-side API used for all server-side operations, including Select, Insert, Update, Delete, Report, Batch Edit, etc. One significant advantage of using a centralized API is that any style of user interface is able to access the same API – this has allowed the co-development of Classic and Touch UI.

Another major advantage in the client-side API is that developers are able to extend their apps with custom behavior utilizing the same data access routines – any access control rules, data controller customizations, and security restrictions will also equally apply to these custom requests.

To access the client API from custom JavaScript, simply call the method $app.execute(options) with the required parameters set on the options object. See a list of available options parameters below.

Property Description Default Value
controller The controller to direct the request to. (required)
view The view of the controller to use. grid1
done
success
Callback function when the request was send and received successfully. First argument contains the results. List of records can be found under the result property equal to the name of the controller.
fail
error
Callback function when the request failed.
command The name of the command to execute. “Select”
argument The argument of the command to execute.
lastCommand The last command name.
lastCommandArgument The last command argument.
pageSize The number of records to return in a single page. 100
pageIndex The page number to return. 0
filter An array of field filter objects. Each object must have 3 properties:
- “field” specifies the field name
- “operation” specifies the filter operation to perform
- “value” specifies the value of the filter. For operations with two operands (such as “between”), specify an array of two values.
values An array of field value objects. Each object can have the following properties:
- “name” specifies the name of the field matching the one defined in the controller.
- “value” specifies the current value of the field.
- “newValue” specifies the new value.
- “modified” specifies that the new value will be used in any Insert or Update expressions. Setting “newValue” will set “modified” to true by default.
selectedValues An array of strings that contain the primary keys of the selected records. Used for batch update.
tags Specify a list of tags that can be processed on the server.
requiresData Specifies if data should be returned to the client. true
requiresAggregates Specifies if aggregates defined on the view should be returned with the request. false
fieldFilter Specifies a list of fields to include in the response for each record. Not setting this value will return all fields.
format Specifies if field values should be formatted when the results are returned. true
includeRawResponse Specifies if the result should include the raw response in the rawResponse property. false

The simplest way to test your queries is to use the Developer Tools Console, available in most modern browsers.

First, browse to your running site in your favorite browser. Press “F12” to bring up Developer Tools. Switch to the Console tab.

Using the Console tab of Developer Tools to test the $app.execute() API.

You may now begin typing in $app.execute() requests in the console. Note the use of console.log(result), which will print the JavaScript object to the console when the request returns.

The following examples will use the online Northwind sample.

Select

The simplest use case for using the API is to request a page of data. See the following example below on how to fetch the first 10 records from the Orders table where the field “ShipCountry” is equal to “USA”.

$app.execute({
    controller: 'Orders',
    pageSize: 10,
    filter: [
        { field: 'ShipCountry', operator: '=', value: 'USA' }
    ],
    done: function (result) {
        console.log(result);
    }
})

The result shown in the Developer Tools Console.

Selecting 10 orders with a filter.

Insert

In order to insert records to a particular table, the request must specify the “Insert” command and a list of field values. This list is represented by the values property. Each field value object contains a field name. Values that will be assigned to the new record are stored in the field value’s newValue property. The primary key of the table is added as a field value object with the property value equal to null in order for the response to return the new primary key of the inserted record.

$app.execute({
    controller: 'Orders',
    command: 'Insert',
    values: [
        { name: 'OrderID', value: null },
        { name: 'ShipCity', newValue: 'San Diego' },
        { name: 'ShipCountry', newValue: 'USA' }
    ],
    done: function (result) {
        console.log(result);
    }
})

See the results below.

Inserting a record using the $app.execute() API.

Refreshing the view in the browser window will reveal the new record.

The new record is displayed in the grid.

Update

When performing operations on an existing record, either the primary key or an array of selected values must be specified. New field values must be specified in the newValue property.

$app.execute({
    controller: 'Orders',
    command: 'Update',
    values: [
        { name: 'OrderID', value: 11083 },
        { name: 'OrderDate', newValue: new Date() }
    ],
    done: function (result) {
        console.log(result);
    }
})

The result is shown below.

Updating an order via the $app.execute() API.

The result can be seen by refreshing the list of orders.

The updated field value is visible by refreshing the page.

Delete

Delete operations must specify the primary key in the values array.

$app.execute({
    controller: 'Orders',
    command: 'Delete',
    values: [
        { name: 'OrderID', value: 11079 }
    ],
    done: function (result) {
        console.log(result);
    }
})

See result below.

Deleting a record.

The rowsAffected property will be equal to “1” if the record was successfully deleted.