Welcome to exercise three, for day twenty-one of 30 days of API Testing.
Goal
Execute an API call that returns some data, then use some/all of that data is a subsequent call.
Objectives
- Send a GET/POST request to an API that returns some data, extract that data and use it in a subsequent call.
- Chaining API calls together
- Gain exposure to many some API testing automation frameworks or tools that support API automation.
Exercise
Choose an API testing automation framework or tool, some suggestions below:
- API Fortress
- Postman
- SoapUI
- RESTAssured (Java)
- SuperTest (JavaScript)
- RESTSharp (C#)
Complete a GET/POST call on an API that reurns some data. Extract that data from the response and use it in a subsequent GEt/POST call. Many test APIs have been posted for challenge 5. A common scenario is having to get authenticated to use some APIs, then send a key/token is all subsequent calls to the APIs.
Example
Using https://automationintesting.online created by Mark Winteringham and myself, do the following:
- Get a token by doing a POST against the auth API at https://automationintesting.online/auth/login endpoint. You’ll need to send the following JSON in order to get a token back.
{
"username": "admin",
"password": "password"
}
- Extract the token and store it
- Do a GET call against https://automationintesting.online/room/, you should get 1-N rooms returned. Extract a room ID from one of the rooms
- Do a POST call against the booking API to make a booking for the room, https://automationintesting.online/booking/. The JSON should look like this, changing the data as you like and ensuring you map to the roomid you stored earlier. You’ll also need to send your token as a cookie.
{
"bookingdates": {
"checkin": "2018-11-01T09:48:25.469Z",
"checkout": "2018-11-01T09:48:25.469Z"
},
"depositpaid": true,
"firstname": "string",
"lastname": "string",
"roomid": <<roomid>>,
"totalprice": 0
}
Share
Post your experiences with the tools you use below.
If you used a different API post the calls you did so others can try them.