How to read GET params in Webhooks when using Workflows

Hi.

I'm trying to implement a Workflow to expose a GET endpoint to retrieve data from the Postgres DB.

I have a WebHook as trigger, and I'd like to know how to pass GET query parameters in the public endpoint.

Could not figure this out yet. Only managed to pass data using POST but I'd like to have a regular GET as this is purely intended to read not to write. I could use headers, but that's not ideal, would like to stick to query params, to pass i.e the id of the user I want to read, or the limit, or some trivial param.

Is this only possible when using POST in Retool? Do you have any specific and comprehensive documentation describing the Webhook triggers API for GET and POST?

Thanks

1 Like

Workflows only support POST webhooks currently.

One idea would be to pass the params via the POST body. Something like:

curl -X POST --url "https://api.retool.com/v1/workflows/123123" --data '{ id: 123, limit:100 }' -H 'Content-Type: application/json'

This isn't ideal, but is the only option currently supported.

Here's a workflow I've built in the past to support CRUD-like operations on a Retool DB

gptdemo CRUD Workflow.json (45.8 KB)

1 Like

is get considered support in future ? I have some use case need that.

Does it mean Workflows are not intended to be used to retrieve data?
I can see they take quite some time when used with GET.
We are trying to use Retool as a CMS for some websites.
Should we connect to the database directly and pull the information from there?

I have a user case for retrive base64 string for img src

1 Like

Hello! There's currently an open feature request to support parsing query parameters in Workflows. For now, it is possible to trigger a Workflow with a GET request that has a JSON body:

Could that work for the time being @Javier_Cobos? Or have you already found another solution?

Yes, I confirm it work for me now. thanks.

But why not just put the data in url instead of json body?

There seem not any advance comparing to use post request.

I'm not aware of a difference on the Retool side of things. Once url parameters are supported they should also be supported for POST requests.

The platform you're making the request from might not let you make a POST request (see this thread, for instance) or might have certain restrictions on the configuration for POST requests, so it could be useful in certain cases to use GET instead. It can also help indicate the purpose of the call in the code where the call is being made.

Hello, @Kabirdas , when I use fetch in JS, it can't allow to pass body to a get request, any idea? thanks.

Hi @AnsonHwang!

Apologies for the late reply here. Not all libraries will support bodies in GET requests. I don't know the full scope of things but it's my impression that scenarios for making a GET request with a body likely aren't as common as making GET requests using query parameters. We can let you know here when that's supported, and in the meantime, I'd be curious to know more about the use case that you're trying to solve!