Getting the response of a API call

First time retool user here — how do I get the result of a POST call? The API I'm using populates the Location field on the header on the response object, but when I try to use query1.headers.location (specifically, I'm trying to show the result of the call in another Retool component), it's accessing the header on the original query, not on the response.

Hi Jessy -
Know we talked through solution on Intercom but want to share with others in the community.
Currently you are unable to access the headers from a POST call response. Retool surfaces the data from a POST call response in but not the headers. We’ll add this our feature request list.
In your specific scenario (and maybe others!) we were able to get the data you needed another way. Details for those interested:
When you create a form with the Typeform API using POST the API returns a link like in headers.location. A GET request to this link gives you metadata about the new form.
How do you access this info using Retool?
location url: Build url using {{""}}
new form metadata: The metadata is returned by the POST /forms request so you don’t need to make a section call, you can just use {{}} to access new form metadata.

Are there any updates on this front?

I’m executing a number of API calls (POST-create Google Doc, PATCH-rename Google Doc, PUT-add permissions to Google Doc) and I would like to be able to tell users when the API returns a non-200 response. Is there anyway I can capture this?

Hey @nacho - we have a PR open that will give you access to this data, working on merging it this/next week :slight_smile:

1 Like

Hello @justin, any news on this? Is this feature live? Thanks

Hey @katiagg! Yep, it’s live. You can read more in the docs here:

Thank you! Found it :slight_smile:
Is there a way to create dynamic URLs?
I successfully retrieved the operation location header and I now want to do a GET request on it but I get an error message saying that only absolute URLs are supported.

@katiagg are you making that GET request via a connected REST API, or like a fetch in a JS Code query?

First one. I created a resource query with just my authentication header and no URL. I’m completely new to Retool so I don’t know if it makes no sense to do that

Could you send over a screenshot of your query?

Thanks for your help!

I could also just create a JS query and do the fetching, waiting and fetching data at the operation location returned. I don't know what is the best practice here

Yep, that’s going to be your best option. We don’t allow fully dynamic URLs in REST queries (you need to have a static base URL and then you can add a dynamic endpoint to that).

When you say you can add a dynamic endpoint, do you mean a URL parameter or is it possible to append something?
All the operation-location URLs have the same base URL - they look like this <baseURL>/<operationID>

Ah cool, so then you can definitely use a REST query! So it's a bit confusing, in Retool there are two options for structured REST requests:

  1. Connect a REST API resource via the resources page
  2. Use a REST Query in your query editor to just put the whole URL in directly

For the former, you add in a Base URL and then can put in a dynamic endpoint in each query. So it would look something like:

So to sum up, you can head to the resources tab, add the API with your Base URL, and then set the dynamic endpoint in the actual query you create in your Retool app.

LMK if this helps!

That's perfect, thanks!
However I don't see the text input after the base URL:

Ah, probably because you put in a few slashes. Can you remove anything after the initial / (i.e the Base URL should be something like, no slash) and then put the fixed part in your query? Like /some/other/directories/{{ dynamic_part }}

Yep, that works! Thank you again for your help :slight_smile:

1 Like

Yay! Glad to hear it :slight_smile:

I'm in the same situation but it's a little different:

I have the problem that I have the ID, so in this example the ID is ['0'], how can I set up the request foreach ID?

Hi @abovethecloud, You could do something similar to this example from our docs. Instead of iterating over each row in your table, you would iterate through the array of IDs, and iteratively trigger your REST API query with each ID passed in the additionalScope option. I hope I understood your question and that my suggestion helps!