Testing

Testing APIs created in API Express.

Any REST API created in API Express can be quickly and easily tested.

Generated APIs

If you generated the APIs then from the main API page click the test link for the group of APIs. You will see a test page with five tabs that correspond to the different operations you can test:

  • FIND
  • GET
  • CREATE
  • UPDATE
  • DELETE

Every tab will show:

  • The URL of the service.
  • The Request payload for the service where you can enter any data to be sent to the service.
  • The Response payload for the service. The response from the service when you test.

Depending on the operation, you might see additional parameters such as:

  • id - the ID of the object you want to retrieve, create or update.
  • count - when selected will return the number of records.
  • offset - marks the ID of the record from which to run the service. The default is 0.
  • limit - marks how many records to return. The default query object count is 100. The maximum number of objects that can be returned is 1000.
  • sort - column(s) to sort by. For example: name or name,-email.
  • Any service parameters defined by you in the service.

📘

Testing secure API

If the Allow only authenticated users to call REST API check box is selected on the Settings page, entering session token is required for testing.

In the Request payload you can enter data that will be sent to the service. For example, you need to enter the correct JSON structure when creating a new record.

To test the API, click the Test button at the bottom of the page.

📘

Get all records (FIND)

To get all the records, select the FIND operation and delete any data between the {..} in the Request payload area.

🚧

Important note!

The response size when testing a service is limited to about 10Mb.

Comparison Query Operators

When running the FIND operation, you can use the following comparison operations to help you with the search:

  • $eq – Matches values that are equal to a specified value.
  • $gt – Matches values that are greater than a specified value.
  • $gte – Matches values that are greater than or equal to a specified value.
  • $lt – Matches values that are less than a specified value.
  • $lte – Matches values that are less than or equal to a specified value.
  • $ne – Matches all values that are not equal to a specified value.
  • $in – Matches any of the values specified in an array.
  • $nin – Matches none of the values specified in an array.

For example, to find records with ID bigger or equal 7:

"id" : {"$gte" : 7}

To find objects with ID of 100 or 200:

"id" : {"$in" : [100, 200]}

Debug Mode

When testing an API that connects to a relational database, enabling the debug mode option will provide more information if there are errors. To turn on the debug mode, go to the Settings page and click Debug mode.

Here is an example of the information you might see when entering the incorrect username or password information for the database:

"details": {
   "SQL Error state": "28000",
   "Vendor Error Code": "1045",
   "Exception": "Access denied for user '9d0599_tes'@'46.164.150.106' (using password: YES)"

Service Caching

When you edit an API Express service and then test it via the Test button/link you will see the changes made immediately.

When you edit an API Express service and then invoke it from an app or an external client (curl or any other client), it could take up to 2 minutes before you will see the changes you made. When you invoke a service in this case and see the old result, this is not a bug. This means the cache for the service hasn't been cleared yet.

This is done to increase performance. For testing purposes, we recommend testing the service from inside API Express as the cache will be updated instantly.

A note on testing from Server Code. Editing and then Invoking an API Express service from a Server Code script, you will also need to wait 2 minutes for the cache to clear. In the future, when invoking from Server Code script will also update the cache immediately.