Skip to content

API testing: add ability to store specific named values from json responses #487

@sampacos

Description

@sampacos

It would be very helpful to be able to store specific portions of web responses in order to use in subsequent requests. For example

  • Send request to serviceX/api/v1/getUserByName?name=sampacos
  • serviceX responds with json such as
{
  "userId": "1245235",
  "name": "sampacos",
  "age": "45",
  "userPreferences": {
    "autoSave": "true"
    "sessionId": "12344123123"
  }
}
  • Send request to serviceY/api/v1/getProjectsByUserId?userId=1245235&sessionId=12344123123

What we need is the ability to store values from specific fields in the json to use for later requests.
In Gherkin, this might look something like this:

Given I use the API named ServiceX
When I add a parameter name with value sampacos
  And I send a GET request to the api/v1/getUserByName endpoint
Then I verify the response code is 200
  And I note the userId in the response
  And I note the userPreferences.sessionId in the response
When I use the API named ServiceY
When I add a parameter userId with the noted value
  And I add a parameter sessionId with the noted value
  And I send a GET request to the api/v1/getProjectsByUserId endpoint
Then I verify the response code is 200

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions