Docs‎ > ‎Debug your API Project‎ > ‎

Test Using the REST Lab

The following image illustrates how you can test retrieval and update logic without writing a program, including provisions for REST ParametersYou can operate on the following end points:

  • Tables - this gives you an instant way of retrieving and loading data, for example. 
  • Views
  • Procedures
  • Resources



REST Lab Screens

The following sections outline the various screens in the Rest Lab.

Request Body

Select your Resource or Table, and click Send Request. The result is shown. Important! In rare cases, you may wish to override the optimistic locking check for PUT requests. Do so with care.

After updates, you can explore the Transaction Summary (Tx Summary) and the Rule Summary to investigate the results of your requests' logic, as shown in the following image:

View the JSON Response

Click GET, POST, PUT, DELETE and view the JSON response in the lower pane. You can then copy selected JSON and copy to the Request area, change it (such as the change to qtyOrdered above), then issue an update by clicking POST or PUT.

Transaction Summary Tab

REST Lab tab TxSummary displays the last POST/PUT/DELETE rule transaction summary- in Summary Information, you can also see the effects on related rows, and the logic execution flow.

Rule Summary Tab

In REST Lab Rule Summary, you can highlight the rule execution for a given PUT/POST or DELETE. The nested or indentation shows the levels of recursive firing of the rules.

Examples

You can manage and test data using the REST Lab. In the following examples, we use Base Tables. We could also use Resources, but Base Tables are available as soon as you create your project and connect to a database, so they are often the simplest.

The REST Lab enables you to rapidly test your API without writing programs, for example:
  • Security - You can examine the Security-augmented SQL as shown here.

  • Updates - You can post/put data as shown in the following sections.

  • Logic - You can issue updates and examine the Log as shown for Allocation. It is often easiest to:
    1. Select a Table (so you don't need to define a Resource).
    2. Perform a Get.
    3. Copy a portion of the resultant JSON.
    4. Return to the Request pane, paste the JSON, update it as desired, select Put, and Send Request. To debug your logic:
      • Use the Log, or
      • Select the debug option.

Read Data - GET

You can retrieve data with filters or sorts using GETREST retrieval requests commonly specify filtering and ordering for the top-most Resource. Since these are coded into the URL, proper escape sequences must be employed (we often use this tool).

Add System Sorts and Filter

Add system sorts and filters or user named sorts and filters to your GET query by selecting Args.

Selecting Args allows different types of Named or Named Filters and Named SortsThe suffix "_uc" uppercases a specific system filter (e.g. equals_uc).

The following code snippet is a GET using a simple filter:
For testing only: You can use filter and order instead of structured filters. You can disable using filters and orders on the Settings tab.

https://val.my.espressologic.com/rest/val/demo/v1/customer?filter=name%3D%27Alpha+and+Sons%27

The following is a GET request for customers with name < 'Shari', ordered by name (descending):
http://localhost:8080/KahunaService/rest/abl/sample/v1/customers?filter=name%3C%27Shar%27&order=name%20desc,balance

Filters are sql WHERE clauses, so you can use familiar functions such as LIKE:

https://val2.my.espressologic.com/rest/val2/demo/v1/customer?filter=name%20like%20%27Alpha%%27

Other SQL rules apply as well, such as interchanging quotes for double-quotes, checking for null (e.g., filter=name+IS+NOT+NULL), and so forth. Explore the other parameters for GET here (see API Information, ResourceList and ResourceSingle). GET simplifies filter testing by providing automatic HTTP escapes:

Load Data - POST

In addition to the example shown on the REST Lab, you can process batches of JSON. For example, you can load this JSON in the API: Demo project using POST:

  {
    "name": "New Cust 1",
    "balance": 0,
    "credit_limit": 900
  },
  {
    "name": "New Cust 2",
    "balance": 0,
    "credit_limit": 5000
  }
]

Alter Data - PUT

A good way to test your Rules is to issue updates from the REST Lab:
  1. Get the data from a table, view, procedure or resource, as described in the previous example.
  2. In Response, select the rows you want to change and paste them into the Request area. Note: This includes the @metadata tag, required for optimistic locking
  3. Make the changes and then click PUT.
Subpages (1): Working with Binary Data