Forum Discussion

maddenapally's avatar
maddenapally
Contributor
6 years ago
Solved

How to add a field to JSON Request using Groovy Script.

Team,   I have scenario like I need to add highlighted json field to Request. Can anyone please help me in this.   { "lastMessage":${Properties#lastMessage_F}, "generationTime":"2016-01-26T...
  • nmrao's avatar
    nmrao
    6 years ago
    Here is the sudo steps to achieve the same.
    Write a script (you can add it in a temporary suite/test case.
    1. You might know to which test step the request needs to be updated based on its service or Method
    2. Based on that, define all method names into a list.
    3. Iterate thru all the test cases and if particular request method is found in your list then do the replacement (which you already have the logic)

    Once the requests are updated, remove that temporary suite/test case.

    So, single script can handle to update and you don't need to add the script in each and every test case.