Overview

In your Test Cases, If some of the Test Data is fetched dynamically from an API Endpoint, we might need to save the Test Data temporarily to use it in subsequent Test Steps. 
We can see how to store Run-time Test Data from REST API Steps in Testsigma in the article - Storing Test Data from REST API Response in Testsigma


Steps for using Run-time Test Data from Response


The saved Run-time Test Data variable value can be used solely in the URL for a REST API Test Step. For this, we just need to append the Run-time Parameter with the URL as it is used in normal Test Steps. Everything else remains the same. The Run-time parameter will be translated into its value when the Test Step is run.


Please check the below guide for more details on usage of Run-time Test Data - How to use Runtime Test Data in Test Steps?


Example


As shown in the previous article, we will be sending a GET request to https://jsonplaceholder.typicode.com/posts/. It returns a Response with a JSON Array containing 100 JSON Objects. We will be truncating the Response to 10 JSON Objects for brevity and it looks like this:

[
  {
    "userId": 1,
    "id": 1,
    "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
    "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
  },
  {
    "userId": 1,
    "id": 2,
    "title": "qui est esse",
    "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
  },
  {
    "userId": 1,
    "id": 3,
    "title": "ea molestias quasi exercitationem repellat qui ipsa sit aut",
    "body": "et iusto sed quo iure\nvoluptatem occaecati omnis eligendi aut ad\nvoluptatem doloribus vel accusantium quis pariatur\nmolestiae porro eius odio et labore et velit aut"
  },
  {
    "userId": 1,
    "id": 4,
    "title": "eum et est occaecati",
    "body": "ullam et saepe reiciendis voluptatem adipisci\nsit amet autem assumenda provident rerum culpa\nquis hic commodi nesciunt rem tenetur doloremque ipsam iure\nquis sunt voluptatem rerum illo velit"
  },
  {
    "userId": 1,
    "id": 5,
    "title": "nesciunt quas odio",
    "body": "repudiandae veniam quaerat sunt sed\nalias aut fugiat sit autem sed est\nvoluptatem omnis possimus esse voluptatibus quis\nest aut tenetur dolor neque"
  },
  {
    "userId": 1,
    "id": 6,
    "title": "dolorem eum magni eos aperiam quia",
    "body": "ut aspernatur corporis harum nihil quis provident sequi\nmollitia nobis aliquid molestiae\nperspiciatis et ea nemo ab reprehenderit accusantium quas\nvoluptate dolores velit et doloremque molestiae"
  },
  {
    "userId": 1,
    "id": 7,
    "title": "magnam facilis autem",
    "body": "dolore placeat quibusdam ea quo vitae\nmagni quis enim qui quis quo nemo aut saepe\nquidem repellat excepturi ut quia\nsunt ut sequi eos ea sed quas"
  },
  {
    "userId": 1,
    "id": 8,
    "title": "dolorem dolore est ipsam",
    "body": "dignissimos aperiam dolorem qui eum\nfacilis quibusdam animi sint suscipit qui sint possimus cum\nquaerat magni maiores excepturi\nipsam ut commodi dolor voluptatum modi aut vitae"
  },
  {
    "userId": 1,
    "id": 9,
    "title": "nesciunt iure omnis dolorem tempora et accusantium",
    "body": "consectetur animi nesciunt iure dolore\nenim quia ad\nveniam autem ut quam aut nobis\net est aut quod aut provident voluptas autem voluptas"
  },
  {
    "userId": 1,
    "id": 10,
    "title": "optio molestias id quia eum",
    "body": "quo et expedita modi cum officia vel magni\ndoloribus qui repudiandae\nvero nisi sit\nquos veniam quod sed accusamus veritatis error"
  }
]


In the same article, we have discussed about saving the id of the 3rd JSON Object i.e the 3rd post into the variable named 'third_post_id'. Let us see how we can use that previously saved Run-time Test Data variable 'third_post_id' in a REST Test Step now.


Unlike the previous URL  https://jsonplaceholder.typicode.com/posts/ which returns a JSON Array of all the available posts, a GET request to URL https://jsonplaceholder.typicode.com/posts/<post_id> returns a JSON Array of post id <post_id>.


We can use the previously saved run-time variable third_post_id and the URL https://jsonplaceholder.typicode.com/posts/<post_id> to return the third post.


Append the runtime variable in the URL for a REST API Test Step as shown below:


Also, we can confirm that the URL is parsed correctly in the Request Details as shown below: