mercredi 29 août 2018

Call Request From Collection Within Pre-Request Script

I am fully aware that there is a way to make an ajax call from within a request's Pre-request script, a la,

const getBooks = {
    url: "http://" + pm.environment.get("host") + "/books",
    method: "GET",
    header: "G-TOKEN:ROM831ESV"
};

pm.sendRequest(getBooks, function(err, books) {
   const ids = _.map(books.json(), function(book) {
       return book.id;
   });

   pm.globals.set("bookIds", ids);
});

pane but is there a way to call a saved request from a collection by name like you can do with postman.setNextRequest('') something akin to...

pm.sendRequest('Get Books', function(err, books) {
   const ids = _.map(books.json(), function(book) {
       return book.id;
   });
});

Aucun commentaire:

Enregistrer un commentaire