【问题标题】:Call Request From Collection Within Pre-Request Script从预请求脚本中的集合调用请求
【发布时间】:2019-02-04 12:32:36
【问题描述】:

我完全知道有一种方法可以从请求的预请求脚本中进行 ajax 调用,例如,

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);
});

窗格,但有没有一种方法可以按名称从集合中调用已保存的请求,就像您可以使用 postman.setNextRequest('') 类似...

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

【问题讨论】:

    标签: api testing automated-tests postman


    【解决方案1】:

    显然,这在当前版本的 Postman 中是不可能的。 github上有一个关于这个确切问题的请求。

    https://github.com/postmanlabs/postman-app-support/issues/4845

    【讨论】:

      猜你喜欢
      • 2021-09-14
      • 2019-04-25
      • 2018-02-28
      • 2020-03-11
      • 2017-01-25
      • 2023-02-01
      • 2015-10-26
      • 2016-10-27
      • 2022-01-16
      相关资源
      最近更新 更多