Open TjorbenWridt opened 3 years ago
Hi @TjorbenWridt!
How is "base64EncodedValue": "base64({{ application.utils.concatValue }})"
working for you? That just resolves to base64(test : test)
for me...
Regardless, there is a way to achieve this using Nunjucks templating.
Firstly, when you create a new sub environment, it isn't automatically activated, so your base environment concatValue
doesn't resolve correctly (and thus resolves to the variable names themselves). If you open the environment drop-down again, and select your environment, they should resolve correctly.
Secondly, in order to use base64 encoding you need to use Nunjucks. Try and use the following base environment:
{
"application": {
"utils": {
"concatValue": "{{ application.credentials.user.username }} : {{ application.credentials.user.password }}",
"base64EncodedValue": "{% base64 'encode', 'normal', application.utils.concatValue %}"
}
}
}
The above environment will use encode application.utils.concatValue
, and render with the Base64 => Encode
tag like this:
After that, you can use application.utils.base64EncodedValue
in the request header, with the correct encoded value.
Let me know if this solves your concern!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Likely related to https://github.com/Kong/insomnia/issues/3919
Describe the bug I have some request in our application which need a double authentication, due to thrid party software which is in use. Therefore I tried to use the base64 encode function of insomnia, but the function can only work with one parameter. So I introduced another variable which stores the concat of the username + : + password. This variable is added to the base64 function. The return value is stored in another variable, which is then used in the customHeader in the request.
In the environment view the value is correct base64 encoded. But if I use the variable with the base64 encoded value in the request view, the generated value is not correct. If you decode the value with another online tool you will see that the decoded value will show {{ application.user.username }} + {{ application.user.password }} .
If the concatValue and the base64 variable are moved to the first level in the JSON it works. Only if it is nested it is not working.
To Reproduce Steps to reproduce the behavior:
Here is an example how the environment looks like:
Base environment:
Subenvironment:
Add the application.utils.base64EncodedValue to the request header value.
Expected behavior The nested value should be base64 encoded and not the variable names.
Screenshots No screenshot as the preview value is not captured. Sorry
Desktop (please complete the following information):