1
votes

I want to test a Rest Webservice with JMeter. I perform a GET request, which returns JSON data. I want to change one attribute and then send it again in a PUT request. Is there a way to do this in Jmeter?

I already extracted the JSON response with a postprocessor, and I can use this response as an input for the next request. But how can I manipulate it? Any ideas?

1

1 Answers

2
votes

You can use a JSR223 POSTProcessor and modify it e.g. with a groovy script:

Add it to the Request whos Response you want to edit and use something like this to edit it:

import groovy.json.JsonSlurper
import groovy.json.JsonOutput

def json = new JsonSlurper().parseText(prev.getResponseDataAsString())

// add the code to edit the JSON Struckture

With that part you can store the JSON in a variable and then simply use it in your update Request

def jsonOut = JsonOutput.toJson(json)
vars.put("jsonBody", JsonOutput.prettyPrint(jsonOut))