need to append json to Request as it is built using Groovy step
I am building JSON using a groovy step that will be different for each iteration of my testcase. I found a code snippet (see below) that will set the request content but that command will replace the request information rather than just append to it. What would I use as the groovy command to just append to the request? Also my JSON is very large (over 240,000 bytes). The command below that is bolded replaces the entire JSON in the request . What I need is the command that would just append the JSON lines I just built.
Here is something I tried to put several pieces of JSON together from small hardcoded JSON snippets using the bolded command (it worked).
request.setRequestContent(JsonOutput.prettyPrint(temp)+ temp2 + JsonOutput.prettyPrint(temp3) + tempEnd)
CODE SNIPPET
def stepName='restStep'
def request = context.testCase.getTestStepByName(stepName).getTestRequest()
def jsonText = '''
{
"id" : "sample id",
"name" : "sample name",
"tags" : [ "sample tags" ],
"address" : {
"street" : "sample street",
"zipcode" : "sample zipcode",
"city" : "sample city"
}
}
'''
request.setRequestContent(jsonText)