ContributionsMost RecentMost LikesSolutionsRe: SoapUI - How to create dynamic array mock responses for REST call Thanks I managed to get this working in the end. I picked up the incoming requests and set them as an array, managed to loop through them and build up a variable containing dynamic responses to each and output the variable as my response. Here's my code for anyone interested, not the prettiest but did the job // Parse the JSON request. def jsonrequest = new groovy.json.JsonSlurper().parseText(mockRequest.getRequestContent()) // Capture values from request requestContext.echoOrderCorrelationId = jsonrequest.orderCorrelationId //Define Incoming Array for CorrelationIds def myarray = new ArrayList<String>(requestContext.echoOrderCorrelationId) def arraysize = myarray.size() //set variables for use in while loop def count = 0 String Response = '[' String Full = '' while(count < arraysize) { //take the correlation ID for item in the loop def CorrelationID = myarray.get(count) //write the body of the response for the item in the loop String Body = '{"orderCorrelationId": "' + CorrelationID + '","customerName": "MOCK Customer","responseStatuses": [{"code": "","message": "OK","severity": "INFO"}]}' //increment the count count++ //check if last iteration if (count < arraysize) { //add comma to continue adding records Full = Response + Body + ',' Response = Full } else { //add ] to finalise response Full = Response + Body + ']' Response = Full } log.info "Body = ${Response}" } //set variable to return for Response Body requestContext.ResponseBody = Response For my response I just default to an OK and use${ResponseBody} to output my variable SoapUI - How to create dynamic array mock responses for REST call I currently have a REST mock service setup for a POST call that responds with different responses depending on the content of the call, this is all working fine but I need this to be able to handle arrays \ multiple requests and respond with the same sized responses accordingly, I'm wondering if this is possible? My current service works as follows, we send a request as per below... [{ "orderCorrelationId" : "85a64706-49c7-4013-a2d2-cb0502300e2d", "customerNumber" : "1234", "testing" : 123, "lineItems" : [ { "test_param_1" : "ABC" }, { "test_param_1" : "GHI" } ], "requestMetaData" : { "correlationId" : "9333c85d-8bd7-425c-81c8-b6d45b40817a" } }] This will respond as follows with the orderCorrelationId being echoed back as part of the response... [{ "orderCorrelationId": "85a64706-49c7-4013-a2d2-cb0502300e2d", "customerName": null, "responseStatuses": [ { "code": "", "message": "OK", "severity": "INFO" }] }] This all works fine, however if there are multiple orders in the request then the response is singular. I'm looking for a way to make this dynamic so that if we get another order included in the request like... [{ "orderCorrelationId" : "85a64706-49c7-4013-a2d2-cb0502300e2d", "customerNumber" : "1234", "testing" : 123, "lineItems" : [ { "test_param_1" : "ABC" }, { "test_param_1" : "GHI" } ], "requestMetaData" : { "correlationId" : "9333c85d-8bd7-425c-81c8-b6d45b40817a" } }, { "orderCorrelationId" : "a89d13da-064d-4fa2-ad7b-7dfbf8815bbc", "customerNumber" : "1234", "testing" : 456, "lineItems" : [ { "test_param_1" : "AAA" }, { "test_param_1" : "CCC" } ], "requestMetaData" : { "correlationId" : "9333c85d-8bd7-425c-81c8-b6d45b40817a" } }] ...then the response would also be an array as per below... [{ "orderCorrelationId": "85a64706-49c7-4013-a2d2-cb0502300e2d", "customerName": null, "responseStatuses": [ { "code": "", "message": "OK", "severity": "INFO" }] }, { "orderCorrelationId": "a89d13da-064d-4fa2-ad7b-7dfbf8815bbc", "customerName": null, "responseStatuses": [ { "code": "1234", "message": "Customer is inactive", "severity": "ERROR" }] }] I'm wondering if this is possible? I found some documentation on doing similar using SOAP but not REST. If this is not possible then I will try to build different responses with different array sizes and try using the incoming array size to determine which response to use Any advice or pointers to useful articles would be appreciated, thanks! Solved[SoapUI 5.6.0] mockRequest is NULL for PATCH call in REST Mock I currently have mock services setup for a few different methods (GET, POST, PATCH). I am trying to build dynamic responses via the Script option and have this working successfully for my GET and POST calls, however I am unable to get my PATCH call working in this way and I'm wondering if this is a limitation of the software. At present the only script applied on the PATCH /orderMetadata data call is to try and capture the request body... // Match based on body def requestBody = mockRequest.getRequestContent() log.info "Request body: " + requestBody I have the following OnRequest scripts running on the solution as per the screen shot below however I cannot capture the request body being passed in log.info(mockRequest.getRequestContent()) log.info(mockRequest.getPath()) Below shows the log script log for a POST /orderMetadata call and a PATCH /orderMetadata call both called with the same request body, the POST is working successfully (note - this has the same script applied as the PATCH) whereas the PATCH is null. Is this an issue with using PATCH? Are there any other commands that would capture the request body so I can branch on this? Note - I have tried renaming the PATCH /orderMetadata call to differentiate it from the POST but this made no difference Thanks