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:
Test Retrieval and Update Logic in the REST Lab
- With your API open, in the Tools section, clickREST Lab.TheRequesttab opens by default. The following image shows this page:
- Complete the following, and then send your request by clickingGET,POST,PUT, orDELETE:
The JSON response appears in theResponsepane. For POST
- Select the endpoint on which you want to operate.Options:
- FunctionFor more information about how to test function endpoints, see the "Test Functions in the REST Lab" section.
- MetadataFor more information about how to test metadata endpoints, see the "Test Metadata Endpoints in the REST Lab" section.
- Select the named endpoint.
- Modify the response by selecting theArgscheckbox.For more information about this checkbox, see Response Formats.
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 Summarycheckbox, the
Include Transaction Summarycheckbox, and the
Exclude Metadatacheckbox. These checkboxes display when you select the
You can revert to the default settings by clearing the checkboxes.
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 sorting for the top-most resource. Because filters and sorts are coded into the URL, employ proper escape sequences.
You can specify filtering and sorting using the URL Encode/Decode tool.
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:
- In the REST Lab, on the Request page, select theArgscheckbox.The following image shows this checkbox:
- ClickAdd Filter.The following image shows the options:
- Choosesysfilter(system filter) andsysorder(system sort) from the drop-down, and then enter your filter parameters. You can uppercase a specific system filter by adding the suffix_uc(for example,equals_uc).
The following code snippet is a GET using a simple filter:
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 (
filter=name+IS+NOT+NULL), and put quotes around the column names. GET simplifies filter testing by providing automatic HTTP escapes.
Test Functions in the REST Lab
You can test your functions in the REST Lab. You can select top-level functions as endpoints from the list. For resource-oriented functions, you can enter the URL directly into the URL field.
You can get to the REST Lab from the function.
- On theBy functiontab, click the top-level function as an endpoint that you want to test from the list of functions. For resource-oriented functions, enter the URL directly in the REST Lab.TheDefinitiontab appears.
- To return to theDefinitiontab for the function, from the REST Lab, clickEdit.
Follow these steps:
- In the REST Lab, select theFunctionendpoint.
- Dooneof the following, and then clickGET:
- To select a top-level function as an endpoint, select the function from the list.The URL that displays in the URL field includes the parameters (string, number, boolean) for the function. Modify this URL with the parameter values that you want to pass into the function.
- To select a resource-oriented function, enter the URL for the function in the URL field.
Test Metadata Endpoints in the REST Lab
- In the REST Lab, select theMetadataendpoint.The metadata endpoints display.
- Select the endpoint, and then clickGET.
Investigate the Results of your Request's Logic
After updates, such as POST, PUT, DELETE requests, 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 Errors in the Response
The following code snippet shows an example of an error message in the response that the
The following table lists the sources of error messages and the format in which they display:
Call your API using Other HTTP Client Tools
You can view examples of how to include the authentication token and call your API from common HTTP client tools, on the
Requesttab, on the
Requestpane toolbar, click
How to call this API.