You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

For this article, we will explain how to create an API capable of responding to HTTP requests. The coding within the API to prepare a valid response will be a topic for another another article (e.g., How do I create a resource?).

First, we need to run the HTTP Framework Setup form (e.g., EXEC NDW_HTTP_FRAMEWORK_SETUP from the System Monitor) and then click on the Resources menu to open the Resource Manager:

When creating an API you are either creating a new resource and defining one or more supported HTTP methods or you are adding new supported HTTP methods to an existing resource. We'll start by creating a new resource. For instance, let's plan on creating a customers resource with an endpoint of /api/customers. Since this resource is directly underneath our /api endpoint, we start by selecting the api resource item in the Resource Manager tree (which is already demonstrated in the above screenshot). We then click on the New Resource button and type customers where prompted and press the Enter key:

This defines the resource within the SRP HTTP Framework environment but it does not yet create the API. This requires two more actions. First, click on one or more methods to support. For now we'll just click on the GET method. Second, click on the Create APIs button. If successful, the following message will appear:

A new stored procedure (aka API module) will exist in your repository and this can be opened with any code editor (we recommend using the SRP Editor because of its native support for enhanced BASIC+ syntax, such as the API keyword). API modules are named after the resource using the pattern <ResourceName>_API.

  • No labels