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

Post Execution Script Question

GregOReilly
Helper

Hello community,

I am needing to test an API and WITE Data to record. (Its a test record in our production env). Doing this is fine, however, the next time I run the same test, I get an error that the data exists.

Can I add a post execution script to validate that the data was correctly added (read the response) and then run a 2nd http api test to delete the data we just added. If the data was not written, I do not want to run the 2nd script, but send an alert instead. (want to avoid repearing failures over and over on a production record)

This proved that my API's are available, working, writing, deleting etc.

There are 20-30 different scenarios we need this to take place as the majority of the services we interact with are SaaS and we have no records of logs/events to tell us when something breaks.

Your help is appreciated.

Greg

2 REPLIES 2

dannemca
DynaMight Guru
DynaMight Guru

In theory, yes, you can.

You can code a javascript to read the response from the POST (response.getResponseBody()) and work with conditions (if|else) to plan the next event as a Delete, or to skip it with api.skipNextRequest(). You can force an alert with api.fail().

Please try the apis for HTTP Monitor, and let us know.

Site Reliability Engineer @ Kyndryl

Thanks, I'll try that and report back.

Featured Posts