- May 02, 2017

Over the past few years, Restlet has had a large community of developers leverage its platform to design, test and host API’s for lots of different purposes. With Restlet Client, developers and testers can use the platform to test and automate APIs. In Restlet Client, a Scenario is an ordered sequence of requests that can be run in one go. A Scenario closely emulates real-life use of the API by a microservice, a web or mobile app.

Ever since we added Scenarios in Restlet Client, we’ve received significant amount of interest for this feature. We really appreciate all the positive feedback and suggestions from the community on how to make this feature more useful.

With the latest release of Restlet Client, we’ve implemented the following set of features to help you quickly and easily combine multiple API requests into Scenarios.

Create a Scenario from Existing Requests

You probably have stored a bunch of requests in your repository. It can be very practical for later reuse. You may also have imported Swagger / OAS API definitions in your repository and want to create Test Scenarios for these APIs.

It’s now easier to create a Scenario from those requests that are stored in your repository. You’ll find an “Extract to scenario” entry on projects and services’ contextual menus:


You’ll be presented dialog and given the option to pick requests you want to include in your scenario. (Tip: filtering capability can be useful when working with big projects)

Finally select where you want to save your Scenario and you’re done!

Complete a Scenario with Existing Requests

It’s exactly the same feature as above but surfaced in a way that enable adding requests to existing Scenarios.

Click on the “Add existing requests” action, choose the requests you want to include in your Scenario and that’s it!


Create a Scenario from Your Request History

Each time a request is sent from Restlet Client, a corresponding entry is created in the History. Requests in History are ordered temporally. It could be useful to save a sequence of requests in a Scenario in order to reproduce it later.

To do so, simply select requests from the History and click on the Save to Repository button.

You’ll be asked to pick a place to store requests. We recommend you create a scenario to store your requests into. This way, you’ll have an ordered sequence of requests that can be run in one go. Perfect to reproduce real-life API usage!


Easily Test Your Web API Thanks to HAR Import

With this release, we’ve also improved our HAR import so that you can build Test Scenarios for your Web app easier.

Here is how to test your Web app API in 5 simple steps:

1. Open your web app in your favorite browser. Open browser developer tools, select the Network tab.


2. The idea here is to use your web app, reproducing a user flow of actions. Your webapp’s frontend will call the backend API as you navigate through the different screens. You can see requests being sent in the browser’s Network tab.


3. Save or Copy all these network exchanges in HAR format. HAR (HTTP Archive) is a JSON-based archive file aimed at storing a web browser’s network interaction.


4. Open Restlet Client, switch to Scenarios tab and import your HAR.


In the HAR import dialog, upload your .har file and select the requests to be included in your test scenario. Filtering capabilities can be used to hide requests that do not target the backend API you want to test (such as images, CSS, Javascript…).


Then, create a scenario to save this sequence of requests in your repository.


Great! You now have an API Scenario that reflects real-life usage of your web API:


5. The final step to build a Test Scenario is to add assertions to your scenario’s requests. Assertions will ensure your API is behaving as expected.

A good starting point is to check the response status code (for example we usually expect a 200 status code for a GET request). You can go further by creating assertions on response headers and body:

Learn more about Web API Tests in the following tutorial: Build an API test for your Web application.

We hope all these improvements will save you time in bootstrapping your API Test Scenarios.

Interested to try out Restlet Client Scenarios? Start now with a free trial of the Restlet Platform!