导入脚本,配置全局变量后请求报错,希望可以支持下postman的全局变量
Memory-9527 opened this issue · 2 comments
Memory-9527 commented
xy-peng commented
正好在重构这个脚本。你可以试下这段代码
let sdk = require('postman-collection'),
newRequest = new sdk.Request(pm.request.toJSON()),
resolvedRequest = newRequest.toObjectResolved(null, [pm.variables.toObject()], { ignoreOwnVariables: true }),
url = new sdk.Url(resolvedRequest.url),
canonicalUrl = url.getPathWithQuery()
let method = request.method
var body = ""
if (method == 'POST' || method == 'PUT' || method == 'PATCH') {
body = resolvedRequest.body.raw;
}
你也可以试试 APIv3 Public Workspace,欢迎反馈。
PS:证书密钥在 Environment 中设置,不在脚本中设置了。
Memory-9527 commented
好的,我研究下,有问题我继续反馈