cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HTTP monitor - Post-execution script - XML format in the response

carlos_ortega
Organizer

Hi,

 

I have a HTTP Check in which I receive the response in XML format. However, I need to use that response in a post-execution script to launch a second request to other HTTP web service.

I have read that Json in the only format in which we could use the post-execution script. So, Is there any way to convert the XML response to a JSON format in the "post-execution script" that we could add in a Http monitor?.

 

Thanks

Carlos

2 REPLIES 2

HannahM
Dynatrace Leader
Dynatrace Leader

Hi Carlos, 

 

you should be fine working with xml without converting it. This is a snippet I used for finding a string in an xml response:

 

var body = response.getResponseBody();
PubDateString = body.match(/<pubDate>(.*?)<\/pubDate>/g)[0];
api.info("PubDateString is : "+PubDateString);

 

Synthetic SME and community advocate.

jkinner
Observer

This solution worked for me to parse some SOAP/XML. 

I wish Dynatrace would update their documentation to tell you all the methods that work in the pre & post-execution boxes for synthetics. It frustrating that you have to come to the community to find out that certain javascript methods work in the boxes. Just tell us up front. The documentation for working with JSON is pretty good. 

Featured Posts