how to preprocess request body before it is processed by virtual asset for correlation
Hello, I would like to preprocess modify request body (e.g., remove blank spaces etc) before the requests is processed by the virtual asset message responders for correlation. may i use groovy extension tool for this purpose or is there any other way of achieving this. if using groovy extension tool, code snipped will be helpful. thank you.
Answers
-
Hi,
I would recommend adding the Extension tool to the Pre-correlation Incoming Request so that your script runs before Responder correlations.
0 -
thanks for the response. do you have a code snippet on how to retrieve the incoming request body, modify it somehow and then save it back to be used in responder correlation.
0 -
Hi,
The easiest way I found was to to use a Text Bank chained to the Pre-correlation Extension tool
Here is the script in the Extension tool
`import com.parasoft.api.Applicationdef modify(input, context) {
payload = input.toString()Application.showMessage("Payload: " + payload)
payload = payload.replaceAll("hello", "world")
Application.showMessage("Modified: " + payload)
return payload
}`Here is the xpath that uses the data bank column modified payload
'${modified}' = '{"greeting": "world"}'Screenshot of the chained tools
0 -
thanks William
0