/
API Generator

API Generator

Before You Start

Wayfast REST APIs consist of Windows executables and stored procedures in a dedicated database. Before starting, visit the database module to associate an existing database to your project or create a new one. To do so, first visit Database > Instances and associate a database server instance to your project. Then visit Database > Database and either associate an existing database or create a new one.

Note: you cannot skip the Database > Instances step. During the Database > Database step, you must select a database server instance. Absent the Database > Instance step, the dropdown on the Database > Database page will not populate.

Wayfast REST API

Access the Wayfast Rest API Module

In the Wayfast development environment, activate a task, select a project, then click on the Connectors button.

 

Observe that the submenu contains entries for REST API and Wayfast REST API.

What Distinguishes REST API from Wayfast REST API?

The Wayfast Connectors submenu has entries for both REST API and Wayfast REST API. The former consists of APIs external to the Wayfast infrastructure. For example, the OpenWeather API highlighted in the REST API document represents an external API with no connection to Wayfast.

Wayfast REST APIs, by contrast, exist within the Wayfast infrastructure and are developed using C# templates generated by Wayfast.

Now click on the Wayfast REST API link.

 

The Wayfast REST API screen has two sections. The upper section displays the environments in which the REST API project has been generated. An environment can be “DBO” for development, any of several testing environments or a client environment.

The lower section lists the database objects (e.g., stored procedures) that tie each API method – a route defined in C# -- to interactions within the project database.  

Before moving onto the next step, make sure you have populated the database with the tables and stored procedures your REST API will need. For more information, consult “Working with Wayfast REST API Stored Procedures.” Wayfast needs these stored procedures to be in place prior to generating a new C# project.

Generate or Update a Wayfast REST API

The Generate button creates a new C# project and updates an existing one.

 

After clicking the Generate button, Wayfast asks for the specific environment (i.e., DBO or a client) in which to generate the API project.

Wayfast REST API projects are generated with a complement of standard stored procedures:

Working with Wayfast REST API Stored Procedures

The configuration of a database Stored Procedure to automatically generate a REST API method, is done from the Database module of Wayfast.

From the Database module. Click on the Stored Procedures option.

Click on the icon of the REST API column.

It will be shown the window with the following fields to capture.

·         Name of the Method

·         Group

·         Method

·         Active

The group field refers to the group where this new API function will be grouped.

The method must be selected between Get or Post as the parameters are required to be send.

With this the Stored Procedure will be visible for the REST API automated generation.

Working with API REST Groups

Access API REST groups administration by clicking on the API REST Group option located in the top right corner menu.

 

The following page will be displayed. This page you can create new groups, and edit or delete existing groups.

Create a new group

To create a new group, click the NEW button.

The following screen will be shown.

Provide a group name and then click the Submit button.

Edit a group

Click the icon in the Edit column.

The following page will be displayed. Here you can modify the group name. Click Submit to save the change.

Delete a group

To delete a REST API group, click the icon in the Delete column.

Download the Current Version of the Wayfast REST API Project

To download the current version of the Wayfast REST API project, click the green arrow icon in the Download column.

Working with the Wayfast REST API Project

After downloading the project, it must be unzipped using the 7-zip utility.

The file is unzipped into three folders.

The Lib folder contains libraries and Wayfast DLLs referenced in the project.

The Packages folder contains the NuGet packages used by the project.

The WayfastRestApi folder contains the project’s source code.

 

In Visual Studio, load the project and note that it targets .net framework 4.7.2.

Compile and execute the project. The following browser window will be displayed.

You can safely ignore this error message. To verify the API code works as intended, navigate to http://localhost:64360/help:

Handling HTTP 500.24 Internal Server Errors

In some instances, you may encounter an HTTP 500.24 – Internal Server Error with the following display:

In such cases, add the following under the <system.webServer> key in your web.config file:

<validation validateIntegratedModeConfiguration="false" />

After saving web.config, restart your project and navigate to http://localhost:64360/help.

Validating Wayfast API REST Methods

To validate the API methods, you need an access token issued by http://localhost:64360/api/login/authenticate. You will need an active Wayfast user name and password, which for testing purposes should be copied into the project’s web.config file.

You can also acquire a token using PostMan. Simply POST a JSON object, as follows:

Copy the returned token from the query output, then switch to the Authorization section in the PostMan. Change the authorization type of “Bearer Token” and paste the token into the “Token” control.

Each REST API has its own URL route, which you can inspect in the Route attribute in the controller code.

Download Previous Versions

To download previous versions of a Wayfast REST API project, click on the link with the generated versions number from the Versioning column.

This will open a popup window with a list of previously generated versions.

To download any of the previously generated versions, click the icon in the Download column.

Querying the Wayfast REST API Project Log

To view the Wayfast Rest API project log of steps undertaken during generation and update, click the icon in the View Log column of the required environment.

The resulting window displays the project generation and update steps sorted by date in descending order.

Settings

To check the settings of the generation and update module of the Wayfast Rest API project, click the menu link in the upper righthand.

And select the Wayfast API Setting option.

On the settings page the codebase version of the Wayfast Rest API project is displayed.

Download the codebase version of the Wayfast REST API project.

To download the codebase version of the Project, click on the icon in the Download column.

Update the codebase of the Wayfast REST API version.

To update the codebase of the Wayfast REST API project, click on the Select files… button.

And select the file compressed on .7z format.

 

Related content

API Calls (Placeholder)!
API Calls (Placeholder)!
More like this
Attach Database
Attach Database
More like this
How to setup the Database in Wayfast?
How to setup the Database in Wayfast?
More like this
Getting ready
Getting ready
More like this
About Wayfast
About Wayfast
More like this
Hello World!
Hello World!
More like this