I’ve only seen our Pre-Request scripts using Javascript.
If you want to kick off some processing in Java, it sounds like you’d want to make that an endpoint in your API to kick off if an empty cache is returned which can be done in Postman using postman.setNextRequest in a conditional.
url = 'https://postman-echo.com/get'
pm.sendRequest(url, function (err, res) {
if (err) { console.log(err); }
pm.test('response should be okay to process', function () {
pm.expect(err).to.equal(null);
pm.expect(res).to.have.property('code', 200);
pm.expect(res).to.have.property('status', 'OK');
});
});
Hi @nicholas.DiPiazza, you cannot directly run a Java program from your Postman collection. But you can expose a local server which executes the program when a particular endpoint is hit. You can then trigger that endpoint conditionally in your collection. For more details, see this thread: