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