I created a workflow with a query block that accesses a rest api resource in my retool project. When I run the query block individually, it runs successfully. However, when I try to run the whole workflow, that block errors - specifically, my API sends an Unauthorized error. When I click 'Edit' on the resource dropdown in the query block and pull up the api connection details, in the base url, username, and password fields, it says " 'environment' is not defined. " and " 'current_user' is not defined. " I'm not sure how this could be happening - I think I have all my settings setup correctly where the workflows can access the resource. How can I make sure that my workflow can access the environment variables??
Hey @Sydney_Murphy! Welcome to the forums.
Are you able to share the details of your resource connection (with anything private blurred out)? current_user
doesn't make sense from a Workflow standpoint since workflows are not user-driven in that no-one in the workflow is doing the processing.
The environment
should be dictated by the workflow's trigger or selected in edit mode (lower left corner of the workflow space) -- however the resources need to have the environments setup in order to be useful here.
Hi thanks for your reply! Here are screenshots from the connection details:
Thanks for the tip about current_user - maybe I need to define a different config variable for the authorization to retrieve the email for the username field? But in terms of the environment, my workflow does have access to the right environments:
and it's listed under the "Usage" tab in the resource's settings - I'm not sure if I'm missing something with that?
Thanks again!
Would you mind sharing a little bit more about how the workflow is intended to operate?
It seems like it needs to authorize depending on who is running the workflow. Is this going to be triggered from an app to return results?
Also, looking at the Base URL setup of your resource, you pretty much just need to fill that in with the APIs root path so I'm not sure you need to use an environmental variable.
Is it possible for this resource to use a service account or an otherwise static set of credentials that you can just plug in to the resource setup? That will alleviate many of the issues. However, if you need each user that runs the process to have credentials you may need to setup this workflow as a user-interactive App instead.
A lot of this depends on the endpoints you are trying to use as well.