Docs‎ > ‎Debugging‎ > ‎

REST Lab

As shown here, select REST Lab in the Logic Designer to test retrieval and update logic without writing a program, including provisions for REST Parameters.  

You can operate on these End Points:
  • Base Tables - this gives you an instant way of retrieving and loading data, for example. 

  • View Tables

  • Stored procedures

  • Resources - you can also test explicitly defined Resources


REST Lab Screens

The sub-sections below outlines the various screens provided in the Rest Lab.

Request

Select your Resource or Table, and click Send Request as shown here.  You will then see the result as shown in the following sections.

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.

Response

You can view the JSON response in the lower pane after you click Send Request.

You can then copy selected JSON and copy to the Request area, change it (such as the change to qtyOrdered above), then click Post or Put to issue an update.  (Select Post or Put using the drop down box on the green SEND button)


Summary Information

As described in Summary Information, you can also see the effects on related rows, and the logic execution flow.




Examples

The REST Lab is very useful in managing and testing your data.  In the examples below, 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 sub-sections below

  • 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 

Reading Data - GET

You can retrieve data with filters or sorts using GET, such as

REST 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).  

Here is a GET using a simple filter:

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

Here 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).

The Get option simplifies filter testing by providing automatic HTTP escapes:



Loading Data - POST

In addition to the example shown on the REST Lab, you can process batches of JSON.  For example, this JSON:

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

can be loaded using POST as shown below:



Updating Data - PUT

As shown at the top of this page, the Samples section describes how to do an update.


Deleting Data - DELETE

Use a similar approach for deleting data, following these instructions.

Subpages (1): Post and Put