HTTP client - hierarchical properties in http-client.env.json

已回答

I'm trying out the new HTTP client. I need to use environments, however, the documentation seems to be a little incomplete. I'm create http-client.env.json with this properties:

{
"development": {
"host": "localhost",
"port": 8080,
"deploy": "deploy_path",
"auth": [
{"user": {"login": "user@login", "password": "password"}},
{"admin": {"login": "admin@login", "password": "admin"}}
]
}
}

and I'm starting a HTTP request with this environment:

POST http://{{host}}:{{port}}/{{deploy}}/rest/some_path
Authorization: Basic {{auth.user.login}} {{auth.user.password}}
Content-Type: application/json; charset=UTF-8

but it's don't work for - auth credentials doesn't load from http-client.env.json.

How i can use hierachical properties for HTTP client?

P.S. Sorry my google translate

1

Sorry for the probably naive and obvious question but does it work in a simpler way? Like this one:

{
"development": {
"host": "localhost",
"port": 8080,
"deploy": "deploy_path",
"username":"actual_login",
"password":"actual_password"
}
}

and:

Authorization: Basic {{username}} {{password}}
0

Vasiliy Yur

Yes, it works, as shown in the documentation. But I asked about the hierarchical properties. My example (with hierarchical properties):

    "auth": [
{"user": {"login": "user@login", "password": "password"}},
{"admin": {"login": "admin@login", "password": "admin"}}
]

involves authorization via user or admin or somewho in varioust tests:

Authorization: Basic {{auth.user.login}} {{auth.user.password}}  or
Authorization: Basic {{auth.admin.login}} {{auth.admin.password}} or
Authorization: ... {{auth.somewho.token}}
etc

Properties like a

   "user_username":"actual_login",
"user_password":"actual_password",
"admin_username":"actual_login",
"admin_password":"actual_password",
"somewho_token":"token",

are working, but it's less usable and clear.

0

Thanks for the extra explanation, got your point now.

Unfortunately, it does not work in this manner at the moment. Please feel free to submit a feature request:

https://youtrack.jetbrains.com/newIssue

0
Avatar
Permanently deleted user

Maybe you need to change json file?

Something like

```json

{
"development": {
"host": "localhost",
"port": 8080,
"deploy": "deploy_path",
"auth": {
"user": {"login": "user@login", "password": "password"},
"admin": {"login": "admin@login", "password": "admin"}
}
}
}

```
0

请先登录再写评论。