vscode-restclient
vscode-restclient copied to clipboard
[Feature Request] Support environment variables in defaultHeaders
Please enhance the rest-client.defaultHeaders setting so that it supports environment variables (specifically in the value of the header, but might as well implement it in both the key and value).
Steps to Reproduce:
- Define a defaultHeader that uses an environment variable, e.g.
"rest-client.environmentVariables": {
"$shared": {
"access_token": "123"
}
},
"rest-client.defaultHeaders": {
"Authorization": "Bearer {{access_token}}"
}
- Submit a request.
The outgoing request contains the raw value
Authorization: Bearer {{access_token}}
But ideally it would contain:
Authorization: Bearer 123
It might also be nice, albeit probably a separate feature request to allow the defaultHeaders to be specified based on the HTTP method. E.g. to specify application/json for POSTs. Something like:
rest-client.defaultHeaders {
"$shared:" {
"Authorization": "Bearer {{access_token}}"
},
"POST": {
"Content-Type": "application/json"
}
}
@loverde nice suggestion, I will consider this feature request carefully.
This feature would be super useful.
Also, thanks for this amazing VS Code extension @Huachao . I might never use Postman again...
Is this issue being worked on at all? I'd love to see this so I can add a unique correlation id to each request to my API for tracing purposes, so I would use the global var {{$guid}}.
I have this implemented in my fork (one line change) but I'm not sure it would get merged. I can share the code if anyone's interested.
And one more vote for this.
@Huachao thank you for the great extension! Is this topic still under discussion, or is there another way to use variables in the default headers I missed? (=
And one more vote for this.