admin管理员组文章数量:1298449
I am trying to create a base request in getToken.http
that I can import and run in my main.http
file. The base request needs three variables, two of which are loaded from the http-client.env.json
file, the credentials for the request, and the third one is a string used in the response handler.
The baseUrl
is loaded from the ...env.json
and the environment is set to 'local'.
getToken.http:
### Post request with a profile variable
POST {{baseUrl}}/getToken
Authorization: Basic {{username}} {{password}}
> {%
client.test("Get Auth Token for " + name, function () {
client.assert(response.body.name === "MY_TOKEN", "MY_TOKEN expected but not found.")
client.global.set(name + "-TOKEN", response.body.value)
})
%}
main.http:
import getToken.http
###
run #Post request with 3 variables(@username={{profile1-username}}, @password={{profile1-password}}, @name='test_string')
It does not properly load the variables from the ...env.json
. When I check the Authorization of the request it looks like this:
Authorization: Basic {{profile1-username}} {{profile1-password}}
As for the response handler, it says: ReferenceError: name is not defined
Unfortunately, there is no example here: import-http-requests-from-other-http-files
本文标签:
版权声明:本文标题:Using IntelliJ's HTTP client, how can I run an imported request and pass it variables to be used in the request and resp 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738498357a2090117.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论