Allow adding of multiple custom headers through environment variables
Hi.
Consider Http client request in a file eg: login.http as follows
POST {{host}}/api/login
Content-Type: application/json
MYAPP-IP: 111.111.111.111
MYAPP-PROD: JZW
MYAPP-SID: 98232fakesessionid800
{
"username": "{{teacherU}}",
"password": "{{loginAppKey}}"
}
MYAPP-IP, MYAPP-PROD and MYAPP-SID are my custom headers that are common to all my API request.
I am trying to add a variable to represent my headers to my environment file http-client.env.json like below:
{
"development": {
"host": "http://localhost:8080",
"teacherU": "someuser@myapp.com",
"teacherP": "EwBolDEpISESTrEwBolDE",
"loginAppKey": "E+jFR8jzDL86ne+OXfplZqLE+jFR8jzDL86ne+OXfplZqLPco4FFW0JtDvjxe8lYrg/EA0PxD9oDJCrwfwSVCpceZNP5sYsD8MMsHstKbhLix7BVKgQ16b1SgIy7Ve7zpIw6ySbAahAo3eXk9jUaSk1hvOvobXIOpva23Nrtxuass8buRT8IxwbmzdWyDrds0htdtd5",
"headers": "Content-Type:application/json \n JZ-SID:98232fakesessionid800 \n JZ-IP:111.111.111.111 \n JZ-PROD:JZW"
}
}
So that I can include the header in my request as below so that all my headers come from my variables. This does not seem to be possible. :
POST {{host}}/api/login
{{headers}}
{
"username": "{{teacherU}}",
"appKey": "{{loginAppKey}}"
}
Is there a way to achieve this so that all of the following conditions are met:
- The headers that I always want to include are defined en-masse in my variables file.
- If I need to remove/add new custom headers, I can make the change in the env variables file and my requests automatically pick up the changed headers.
Please sign in to leave a comment.
Variable header names are not supported yet: https://youtrack.jetbrains.com/issue/WI-40447
But your request is even more specific as it requires being able to set multiple headers from one var, so please submit a new request using this template: