I am stuck. I am new to groovy scripting. How do I parse out theOrchestrationId, CenterId and AddressId of the below response? All are unique, dynamic and generated in the application. I need these...
aah - I just noticed you'll need to remove 2 instances of the double quotes on top of what I've already provided. So after running the above script I mentioned to remove the '\' chars, you'll also need to remove the " chars opening and closing the message object's contents.
Changing the below snippet
to the following:
so you need to update what I said before to something like the following:
def content = context.httpResponse.responseContent
content = content.replaceAll( "\\", "" ) // to replace the '\' char with blank
content = content.replaceAll( "\"{", "{" ) // to replace the "{ to {
content = content.replaceAll( "\"}", "}" ) // to replace the "} to }
log.info( content )
context.httpResponse.responseContent = content
As I stated before - the json escaping confuses me - I've just read up a little and it isn't as confusing as I thought - so I think I've got the escaping correct now - but what you need is something pretty close to above.
The response is returning in JSON, not XML. This application only sends and accepts json. I am not sure of what is wrong with the script in line 7. I have attached the request and response and the script you provided.
Right i can see we've misunderstood each other. I wasnt saying add what i put in a groovy step (although you can). All your responses are json and they all have escaped json in an eventmessages object...right?
As this escaped json is going to occur for all your responses im guessing i said use an events handler instead. Thst is, click on the Events button below the maintoolbar (next to Preferences button), click on the green plus and select RequestFilter.afterRequest.
Then add the code i gave you in the input field below. What this will do is alter the response for every request in your project so youll never get escaped json in your responses.....so you wont need any further groovy allowing you to rely on the OOB functionality to assert and property transfer.
Im typing this out on my phone so i cant see your last post but i remember you having an import declaration and another line where you'd parsed the response that you dont need with the event handler content.