Backend Workflow with URL parameters

Hey guys
I would like to use the same Backend Workflow API endpoint for various places, for example: https://myapp.bubbleapps.io/version-test/api/1.1/wf/myendpoint only using URL parameters such as: https : //myapp.bubbleapps.io/version-test/api/1.1/wf/myendpoint**?id=1**

Then I wanted to identify if the Request was sent to ID = 1, I activate a different trigger for whatever is sent to ID = 2

Does anyone know if this is possible?

You need to set parameters in the workflow and send the request with a json payload with the parameters.
image

1 Like

Yes, thats work! Thank you!

Great :slight_smile:

as every solution generates a problem, if used like this, I lose the option to use the body content as requested

example:
if I send content to that same endpoint with a url parameter, I can’t use what comes in the body of the request as dynamic data

I needed to access the request body as well, as is possible with Detect request data

the payload that you send to the endpoint can be organized as you want following the logic you want.
The json body and the request headers are the only data that you have access to.

I’m sending a json payload to the same webHook, only with a URL parameter, example: /api/1.1/wf/myendpoint/?id=1

with the json below:

{
“person”: {
“name”: “William”,
“age”: 30,
“occupation”: “Developer”
}
}

but that way I can’t access person.name, for example

image

I receive the error code: 400
"message": "Missing parameter for workflow myendpoint: parameter person.name"

why don’t you send the id in the json payload as well?

because whoever is sending the payload does not send the id in the body, only the content. if you sent the id in the body I wouldn’t need to add it as a URL parameter.

then I can only set the URL to which they should send the webhook, but I cannot change the content that is sent, so I can set it to send the webhook to my endpoint/?id=1, 2, 3 etc

and then I will know from whom the request is coming
but I need to access the data that comes in the body which is a json object

AND… if I use Detect request data, I can access the body, but I don’t know where it’s coming from, then I’d have to create another workflow and that’s not scalable for me

My understanding is that you can detect data and have access only to parameters in the body, or you can set parameters manually and have both data from the body and the query string but without the ability to define nested data.
It looks like you either include the id in the body as a parameter or you flatten the structure of the body.

On a side node if you want to identify the request have you considered to use auth on the endpoint?

I’m trying to do this with the Telegram Bots API. When you have a bot, you set an endpoint for the bot to send events using https://api.telegram.org/bot[bottoken]/setWebhook . In this case I want to use just one Workflow API to receive several, but the parameters that telegram sends do not include the Bot ID that is sending. So to identify which bot is coming from (if I have more than 1 with the same defined URL) I would need to set the URL as a parameter when defining it in /setWebhook.

You probably need a proxy then: let telegram call the proxy endpoint with both query parameters and json body and forward the request to the backend workflow with the query parameters included in the body.

Proxy?
Can you give me an example? It would help a lot!!

  • telegram sends a request to yourproxy.com/bot?id=1 with a body {"hello":"world"}
  • your proxy server forwards the request to yourbackendapi.com with a body {"hello":"world", "id":1}
  • the backend api does its stuff and replies to the request from the proxy
  • the proxy responds to the original request from telegram.

There are countless ways of doing it.

LOL, I discovered.
When we set /setWebhook, we can set header param “secret_code”. I hadn’t read that in the API.
Thanks a lot for the answers!