variables in variable statements? #270
-
Would it make sense to make it possible to use variables within variable statements like the following, thus making it possible to put them into env files or imilar which would make it even more flexible? @user = "some_username"
# @env-stdin-cmd AID jq -r '.results[] | select(.desc == "{{user}}") | .id'
GET https://cloud.mongodb.com/api/atlas/v2/groups/{{project}}/apiKeys |
Beta Was this translation helpful? Give feedback.
Answered by
gorillamoe
Oct 8, 2024
Replies: 2 comments 4 replies
-
For these kind of computations, using scripts might be the perfect fit. Can you try if this fits your needs? |
Beta Was this translation helpful? Give feedback.
2 replies
-
Implemented in v4.2.0: @ENV_USER = some_username
@ENV_PROJECT = project_name
POST https://httpbin.org/post HTTP/1.1
Content-Type: application/json
Accept: application/json
{
"project": "{{ENV_PROJECT}}",
"results": [
{
"id": 1,
"desc": "some_username"
},
{
"id": 2,
"desc": "another_username"
}
]
}
> {%
client.global.set("AID", response.body.json.results.filter(item => item.desc === request.environment.get("ENV_USER"))[0].id);
%}
###
POST https://httpbin.org/post HTTP/1.1
Content-Type: application/json
Accept: application/json
{
"id": "{{AID}}"
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
gorillamoe
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Implemented in v4.2.0: