Steps to Reproduce:
lidarr.http:@root = http://localhost:8686/api/v1/
@calendar = calendar?start={{start}}&end={{end}}&includeArtist=true
@start = 2018-01-01
@end = 2018-12-31
###
GET {{root}}{{calendar}}
###
curl --request GET \
--url 'http://localhost:8686/api/v1/calendar?includeArtist=true&end=2018-12-31&start=2018-01-01'
@start and @end variables to be above the @calendar variable like this:@start = 2018-01-01
@end = 2018-12-31
@calendar = calendar?start={{start}}&end={{end}}&includeArtist=true
curl --request GET \
--url 'http://localhost:8686/api/v1/calendar?includeArtist=true&end=%7B%7Bend%7D%7D&start=%7B%7Bstart%7D%7D'
I am not terribly bothered by this now I've figured out a way around it but it isn't obvious as to why it works only like this. I'm not sure using variables in variables was even mentioned in any documentation I found. Not sure if it's relevant but the generated URL has also swapped the order of query parameters.
@SimonDever actually it just happens to work. We don't support for variable value references other variables, the reason you work is related to current variable resolving logic in code. I will check if any file variables exist in declaration order, so in your case, I found calendar there, I will replace the calendar in request by its value, which introduces a new variable start. And the resolving logic continues, the next checking variable is start, and it's there, I replace it too. That's the reason why it works. I will modify the implementation later.
Modify to remove the ability to use variables in other variables or modify to be able to declare them in the reverse order as well?
@SimonDever I am planning the feature that the actual value of a file variable can reference other request variables and file variables.
Referencing environment variables from a file variable used to work for me. Looks like something in 2018/6/28 release broke it. Would be great to see it working again.
@vladvino I will fix this ASAP.
@Huachao Is there an issue for the feature enhancement of reusing one file variable in another file variable?
@mchelen I am afraid not. And I will implement the feature that file variables can depend on any custom variables(environment, file and request variables) finally.
Would/Could this also support storing "resolved" dynamic variables in variables? I would like to store a date in a variable so it can be used multiple times in an array of objects being posted
@enteredDate = {{$datetime iso8601}}
So it could be used in a post like the following
[
{
"firstName": "joe",
"enteredDate": "{{enteredDate}}"
},
{
"firstName": "bob",
"enteredDate": "{{enteredDate}}",
}
]
@schallm Thanks for your suggestion. The file variables definition can already support referencing request variables, and allowing supporting other types of variables like System Variable, Environment Variables and File Variables are in my todo list.
@SimonDever @vladvino @mchelen @Mellbourn @schallm I have implemented the feature that file variables can reference other file variables. And the work that references environment variables and system variables is still WIP.
Do you have issues open for those other things mentioned here and can I close this or do you want to keep it open until the environment variables/system variables work is complete?
Let's keep it open, I will finally close this issue before next release
@SimonDever @vladvino @mchelen @Mellbourn @schallm I have implemented the feature that file variables can reference file/system/request/environment variables. I will publish this feature in next release
@SimonDever @vladvino @mchelen @Mellbourn @schallm you can try the latest version 0.20.4 to verify
I can confirm my use case is now supported. One interesting/awesome thing is that the dynamic variables are re-evaluated each time "Send Request" is clicked. So in my example above, enteredDate is updated to "now" with each request.
Thanks for implementing this feature!
Most helpful comment
@SimonDever @vladvino @mchelen @Mellbourn @schallm I have implemented the feature that file variables can reference file/system/request/environment variables. I will publish this feature in next release