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
You can test retrieval and update logic using the REST Lab.
- With your API open, in the Execute section, clickREST Lab.The Request page opens by default. The following image shows this page:
- Complete the following and then send your request by clickingGET,POST,PUT, orDELETE:
Requestcontent-type as application/json or application/xml.The JSON response appears in theResponsepane. The status code and Content-Type are displayed.
- Select the endpoint on which you want to operate.Options:
- Table. Tables give you an instant way of retrieving and loading data. Select 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.
- Select the named resource.
- View the URL used to send to API Server.
- Modify the response by selecting theArgscheckbox.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.
- In the REST Lab, select theFunctionendpoint.
- Dooneof 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.
- Send your function request by clickingGET.
Test Metadata Endpoints
- In the REST Lab, select theMetadataendpoint to view the metadata endpoints.
- Select the endpoint.
- Send your request by clickingGET.
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:
- In the REST Lab, copy the JSON response that appears in the Response pane.
- Change it, for example, toqty_Ordered.
- Copy the JSON response to the Request pane.
- Issue an update by clickingPOSTorPUT.
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 for Explore Allocation Example. It is often easiest to:
- Select a table (so that you do not need to define a resource).
- Copy a portion of the resultant JSON and paste it in the Request pane.
- Update it as desired.
- ClickPUTto 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.
You can use the URL Encode/Decode tool.
For more information about using GET, see GET.
Specify Include Rule Summary, Transaction Summary and Exclude Metadata
You can specify whether REST requests include or exclude rule summary and transaction summary. Select the
Include Rule Summarycheckbox. You can also specify whether to include or exclude the metadata from the REST requests. You can undo the selection to revert to the default settings.
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.
- 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.
For more information about the other parameters for GET, including
ResourceSingle, see Quick Reference.