Pass variable to create URL in a GET API

I have a GET query defined:

Within an App, I can pass the {{docVariable}} and the query executes correctly:

URL includes the passed variable:
image

I am trying to move this process into a workflow. I can make it work like this:

But I need to put the GET into a function block so I can re-try until I receive a specific status in the 200 response (at least as I understand it from spending time going through other posts). However, when I do that, I can't seem to pass the variable to create the URL correctly:


The error code says:
{"data":null,"error":"(line 5) Error: {"error":{"code":"NotFound","message":"Resource not found.","innererror":{"code":"OperationNotFound","message":"The requested operation was not found. The identifier may be invalid or the operation may have expired."}}}"}

The function is an import of the same GET query defined in the App and works if I test it with a string

What am I doing wrong here in trying to pass in the docVariable string from the workflow?

I - and others - are having a similar issue but no word yet from Retool. Can someone from Retool at least chime in to say that they are looking into this critical bug!

1 Like

I'm not seeing a parameter define in the workflow function. I think it should be something like

Screenshot 2023-10-20 at 11.50.55 AM

Also, have you seen the built-in retry functionality?
Screenshot 2023-10-20 at 11.54.07 AM

1 Like

Yes - needed the parameter. I had not done this because the UI shows it as an error when you do:
image

Thanks for the heads-up on the built-in retry, but I'm not using it since it only works in the event I get an actual 400-type error and I need to retry based on the status returned in a 200-type response.

Thanks, @matth! :raised_hands:

Definitely :clap: for @matth for the quick save!

@Tess - can you surface the "Hard Error" tooltip which is actually a "Stern(?) Warning" to the Dev team to review? I'm sure I'm not the only one who would be thrown off by it.

Yes, definitely! :pray:

You may still like to handle the retry yourself but something like this might work

I'm leveraging code from Retry API call? that retries [n] times (10 in the example below) and then throws an error. Thanks for the alternate approach as well.

const var= "some parameter";
const maxTries = 10;                   // how many times should we retry

for (let i = 0; i < maxTries; i++) {
  const result = await functionForGET(var);          // try to run the function(*params*)
  if (result.data.state === "running") {             // set response that triggers repeat
    await new Promise((r) => setTimeout(r, 10000));  // if met try again
    continue;                                        // otherwise move on
  }
  return result;
}

throw new Error("Max tries reached");  // Uh-oh. Tried [n] times and it didn't work