Using variables to make a dynamic “connectors out” script

I'd like some help to solve what is most definitely a basic problem (being a beginner, I couldn't find the solution myself or by browsing the internet).

My goal is to make an API call (to an external API) using variables defined in earlier steps of a process (meaning that each form should lead to a different API call). I know for sure the API is working as intended. I thought of something looking like that in my "connectors out":

return 'http://localhost:8080/test/' + commande.getQty(); 
(with "commande" being in my pool variable, "qty" is a variable I've defined and "getQty()" a method I've created)

But when I run it, no matter how I fill my form, all I get is a call to "http://localhost:8080/test/".

Is there a way to get the value of a variable defined in a previous step ? If there's none, is it possible to do that with an API call ?