Test your API Using the REST Lab

Test your API Using the REST Lab
You can test retrieval and update logic without writing programs, including provisions for REST parameters, using the REST Lab. You can manage and test data using the REST Lab.
In this article:
How to Test Retrieval and Update Logic
  1. With your API open, in the Execute section, click
    REST Lab
    The Request page opens by default. The following image shows this page:
    Screen Shot 2017-06-15 at 6.58.17 PM.png
  2. Complete the following and then send your request by clicking 
    , or 
    1. Select the endpoint on which you want to operate.
      • Table. Chose this option to give you an instant way of retrieving and loading data. Choose this option to test top-level or resource-oriented functions.
        For more information about how to test functions, see the "Test Functions from the REST Lab" section.
      • View
      • Procedure
      • Resource
      • Function 
      • Metadata
      The available endpoints are available.
    2. Select the named resource.
    You can specify the
    content-type as application/json or application/xml. 
    The JSON response appears in the 
     pane. The status code and Content-Type are displayed. 
  3. View the URL used to send to API Server.
  4. Modify the response by selecting the 
     checkbox.For more information about this checkbox, see Response Formats.
Test Functions from the REST Lab
You can use the REST Lab to test your functions. You can select top-level functions as endpoints from the list. For resource-oriented functions, you can enter the URL directly.
  1. In the REST Lab, select the
  2. Do
    of the following:
    • To select a top-level function as an endpoint, select the function from the list.
      The function's parameters are pre-filled in the URL (string, number, boolean). Modify the URL with the parameter values to be passed into the function.
    • To select a resource-oriented function, enter the URL for function in the field.
    The following image illustrates the options:
    Screen Shot 2017-06-15 at 7.03.01 PM.png
  3. Send your function request by clicking
Test Metadata Endpoints
  1. In the REST Lab, select the
    The metadata endpoints display. 
  2. Select the endpoint. 
  3. Send your request by clicking 
Investigate Results
After updates (for example, POST, PUT, DELETE), you can investigate the results of your request's logic by exploring the following summaries:
  • The transaction summary
  • The rule summary
For more information about how to display a summary of the rules that were executed in a transaction and how to obtain the rules summary, see Transaction Summary.
View the JSON Response
As an example, you can:
  1. In the REST Lab, copy the JSON response that appears in the Response pane.
  2. Change it, for example, to
  3. Copy the JSON response to the Request pane.
  4. Issue an update by clicking 
In the following examples, the base tables are used. You can also use resources, but base tables are available as API endpoints (including views and procedures) as soon as you connect to a database. So base tables are often the simplest.
You can test your API using the REST Lab. For example, you can:
  • Examine the security-augmented SQL.
    For more information about examining this SQL, see Security Examples.
  • POST/PUT data.
For more information:
    • About issuing an insert using the REST Lab, see POST.
    • About issuing an update using the REST Lab, see PUT.
  • Issue updates and examine the log, as shown in the Allocation Example. Do the following:
    1. Select a table (so that you do not need to define a resource).
    2. Click
    3. Copy a portion of the resultant JSON and paste it in the Request pane.
    4. Update it as desired.
    5. Click 
       to send your request.
You can debug your logic using the log or the debug option.
For more information, see The Request Object.
Retrieve Data with Filters or Sorts using GET
You can retrieve data with filters or sorts using GET. REST retrieval requests commonly specify filtering and ordering for the top-most resource. Because filters and sorts are coded into the URL, you must employ proper escape sequences.
For more information about using GET, see GET.
Include Rule Summary, Transaction Summary, and Exclude Metadata
By default, REST requests include the rule summary and the transaction summary and exclude the metadata. You can specify whether REST requests include or exclude this information. To include this information in REST requests, select the
Include Rule Summary
checkbox, the
Include Transaction Summary
checkbox, and the
Exclude Metadata
checkbox. These checkboxes display when you select the
You can revert to the default settings by clearing the checkboxes.
Specify System Sorts, System Filters, and User Sorts
You can allow different types of named filters and named sorts. Specify system sorts and filters or user sorts and filters to your GET query.
Follow these steps:
  1. In the REST Lab, on the Request page, select the
    The following image shows this checkbox:
    Screen Shot 2017-06-15 at 7.09.56 PM.png
  2. Click
    Add Filter
    The following image shows the options:
    Screen Shot 2017-06-15 at 7.13.21 PM.png
  3. Choose
     (system filter) and
     (system sort) from the drop-down and then enter your filter parameters. You can uppercase a specific system filter by adding the suffix 
    (for example, 
The following code snippet is a GET using a simple filter:
You can test using filter and order instead of named filters. You can also turn off regular filters and sorts.
For more information:
The following code snippet is a GET request for customers with name < 'Shari', ordered by name (descending):
Depending on your database and settings, you might require quoted identifiers, such as shown in the following code snippet (for the
http://localhost:8080/rest/default/demo/v1/demo:customer?filter="name" like 'A%' 
Filters are SQL WHERE clauses, so you can use familiar functions such as
Depending on the database type to which you are connected, there are other SQL syntax rules that can affect filter results. For example, you can interchange quotes for double-quotes, check for null (
), and put quotes around the column names. GET simplifies filter testing by providing automatic HTTP escapes.