【问题标题】:add aws signature to the postman script using pm.sendRequest使用 pm.sendRequest 将 aws 签名添加到邮递员脚本
【发布时间】:2022-01-21 16:27:38
【问题描述】:

我想使用邮递员预取脚本从受 aws 签名保护的 api 刷新我的应用程序机密。我能够进行这样的基本身份验证。但是我需要一个 aws 签名认证


var url = "https://some.endpoint"
var auth = {
  type: 'basic',
  basic: [
    { key: "username", value: "postman" },
    { key: "password", value: "secrets" }
  ]
};

var request = {
    url: url,
    method: "GET",
    auth: auth
}

pm.sendRequest(request, function (err, res) {
    const json = res.json() // Get JSON value from the response body 
    console.log(json)
});

【问题讨论】:

    标签: postman postman-pre-request-script


    【解决方案1】:

    您好,只需创建一个正常工作的普通邮递员请求,然后通过在测试脚本中添加以下行将该请求复制到变量

     pm.environment.set("awsrequest", pm.request)
    

    现在您可以使用 awsrequest 变量在 pm.sendRequest 中发送使用

     pm.sendRequest(pm.environment.get("awsrequest"))
    

    【讨论】:

      猜你喜欢
      • 2021-10-08
      • 2020-09-27
      • 1970-01-01
      • 2018-01-04
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 2017-06-10
      • 1970-01-01
      相关资源
      最近更新 更多