Developing APIs‎ > ‎Debugging‎ > ‎

Test your API Using the REST Lab

You can test retrieval and update logic without writing a program, including provisions for REST parameters, using the REST Lab.

For more information about REST parameters, see GET.

How to Test Retrieval and Update Logic

The following image illustrates how to test retrieval and update logic using the REST Lab:


  1. Go to Execute REST Lab, Request tab.
  2. Select the endpoint. You can operate on the following endpoints:
    • Table. Tables give you an instant way of retrieving and loading data.
    • View
    • Procedure
    • Resource
  3. Select the named resource.
  4. Send your request by clicking GET, POST, PUT, or DELETE. The JSON response appears in the Response pane.
  5. View the URL used to send to API Server.
  6. Test the response formats by clicking the Args checkbox.
    For more information about the Args checkbox, see GET.

Investigate Results

After updates, you can investigate the results of your requests' logic by:

  • Exploring the transaction summary on the Run, REST Lab, Tx Summary tab.
  • Exploring the rule summary on the Run, REST Lab, Rule Summary tab.
The following image shows the Run, REST Lab, Request tab:

View the JSON Response

When you send your request by clicking GET, POST, PUT, DELETE, the JSON response appears in the Response pane. You can copy selected JSON to the Request body pane, change it (such as changing to qty_Ordered), then issue an update by clicking POST or PUT.

Examples

You can manage and test data using the REST Lab. In the following examples, the base tables are used. You can also use resources, but base tables are available as soon as you create your API project and connect to a database, so they are often the simplest.

You can test your API without writing programs using the REST Lab. For example:
  • Security. You can examine the security-augmented SQL.
For more information about examining this SQL, see Security Examples.
  • Updates. You can 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.
    1. Select a table (so you don't need to define a resource).
    2. Click GET.
    3. Copy a portion of the resultant JSON and paste it in the Request pane, update it as desired, click PUT, and Send Request.
You can debug your logic using the log or the debug option. For more information, see View Logging Information or 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. Since these are coded into the URL, you must employ proper escape sequences (we often use the URL Encode/Decode tool).

For more information about using GET, see GET.

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:

  1. Go to Execute, REST Lab, Request tab.
  2. Select the Args checkbox. The following image shows this checkbox:

  3. Click Add Filter. The following image shows the Filters section of the page:
  4. Choose sysfilter (system filter) and sysorder (system sort) from the drop-down, enter your filter parameters. You can uppercase a specific system filter by adding the suffix _uc (for example, equals_uc).
Examples

The following code snippet is a GET using a simple filter:

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

For testing only: You can use filter and order instead of structured filters. You can also turn off regular filters and sorts.

For more information:

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://server.acme.com/rest/acme/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 (for example, filter=name+IS+NOT+NULL), and so forth. GET simplifies filter testing by providing automatic HTTP escapes.

For more information about the other parameters for GET, including ResourceList and ResourceSinglesee Quick Reference.