Page 1 of 1

API user_variables hard to create and not visible in API while XML export shows them!

Posted: Thu Dec 20, 2018 12:20 pm
by emcodem
Hi again :-)

For the webinterface, i need to provide a manual on how to create user_variables but it looks like this part is somehow buggy. Maybe there are workarounds already known?
user_Var.png
user_Var.png (59.04 KiB) Viewed 7764 times
What i do when creating a new variable is to open the variables editor on a random node, e.g. populate varaibles. In the "Select variable:" window, i select the "User" tab (if any) and thne rigthclick - New. After that, the corresponding variable does not exist in the workflow export xml, nor in the API
http://localhost:65445/api/json/v1/work ... 1220091541

What i could already figure out is, that the created user_variable from above will exist in the exported workflow xml as soon as i started some job after registering the new variable.
But i did not yet manage to get out what is needed to get the variable visible in the API calls. I know it is possible because i already had some variables in the API calls but i don't know how to get there intentionally.

By the way, i did not yet manage to get ANY user_variables in the details call, even when the above one already shows the variable. I would love to use the details call, as the other one contains a lot less information. But currently i need to utilize both calls to get out all details ;-)
http://localhost:65445/api/json/v1/workflows/details


Cheers!
emcodem

Re: API user_variables hard to create and not visible in API while XML export shows them!

Posted: Thu Dec 20, 2018 6:00 pm
by admin
Hi emcodem,

A while ago I fixed several issues regarding dealing with user variables in different scenarios. The issues you're reporting are some of them so stay tuned for the next version. I will send you a beta-build so you can test your nice web interface :-)

-steinar

Re: API user_variables hard to create and not visible in API while XML export shows them!

Posted: Thu Dec 20, 2018 6:09 pm
by emcodem
Hey Steinar,

lots of thanks for the quick response, looking forward to the beta but take your time...
Actually i thought there might be a simple workaround as it seems to work sometimes... I guess one just has to know where to click in order to present the variable to the API as well?

Thanks!
emcodem

Re: API user_variables hard to create and not visible in API while XML export shows them!

Posted: Wed Dec 26, 2018 9:41 pm
by emcodem
Hey steinar,

very good news, i was able to find a workaround:
The user_variables are only presented to the api when they are (or have ever been) actually used in a value field.

So i can create and edit variables but only when they are used in some value field (i used populate to test, i believe it works with any value field), they are visible to the API.
populate_bug.png
populate_bug.png (13.94 KiB) Viewed 7742 times
In the end this makes somehow sense.. why should non used variables be presented to the API ;-)
This way i can write a nice user manual how to use the mighty variable feature for job creation on the WebUI

Cheers!
emcodem

Re: API user_variables hard to create and not visible in API while XML export shows them!

Posted: Thu Dec 27, 2018 9:19 am
by admin
User variables not used in a workflow will not be exposed in the API (or the exported XMLs). As you point out, this makes sense and it's by design.

-steinar