Pass API response to a Backend Workflow API parameter

Hi everyone, first post here as I haven’t been able to find any response to my question!:slight_smile:

Custom Event:
Step 1: Call an external API that returns a list of items in structured JSON Format.
Step 2: Trigger a Backend workflow API and pass the JSON from step 1 as a parameter.

The problem is that I cannot seem to be able to pass that data because the parameter “type” from my Step 1 api isn’t showing up as an options

contrary to a custom event parameter where I am able to select a type coming from an api call

image

My questions is how can I pass the API response I get from step 1 to my api workflow?

Did you set up the external API call in the API connector? Did you set the right type? Did you initialize?

Yes the API is setup in the API connector and is working properly, I’m using it already in multiple workflows, but I want to pass the response from the api (JSON list) in a parameter of a backend workflow.

My goal is basically to loop all items from the API response. So I need to pass that api response back to my recursive api.

Got it. so in step 2 take the body of the response. If it’s not available, the call prob has to be modified to make it available.

So in step 2 when I try to pass my api response in my workflow api parameter, it shows up in red

image

That’s because the parameter type of my api response isn’t available in my workflow api

as you can see I have no option to select the type of my api response there, I can only select the basic types such as Text.

1 Like

Two routes:

  1. Create backend workflow that takes a parameter for each parameter in your JSON (e.g if your JSON has a name and description parameter, you’d create these in your backend workflow). Then, schedule API workflow on a list of your JSON objects and set the parameter to This object's X.

  2. Create backend workflow that takes a list of parameters in your JSON like above, except with a list of fields. In the backend workflow, you can reference each parameter’s list item # 1, then when it schedules itself to run again recursively remove the first item from the list of each parameter.

I’d choose option 1 as it’s ideal for most use cases.

Nice! I was trying not having to add each of my JSON objects as parameters, but it works well!

image
image
image

Just bear in mind with the first method that you’re a bit screwed if one of the parameters is empty or duplicated because your list will shifted be out of line… I’d very much recommend the schedule API workflow on list approach

Hmm not sure to understand what you mean there, could you clarify?

The issue with the schedule API workflow on a list is that you need to put a fixed interval in seconds, which could cause a process to occur at the same time as another if the previous one wasn’t completed yet. I want to make sure this doesn’t happen as it can create memory overload in my api provider (apify).

You don’t. Leave it blank and it will run once every second or so. Perhaps the Bulk create / API is best for you here if you need to create lots of things in one go (synchronously).

If we have a simple list of two objects, let’s call them:

Apple
name: apple
colour: red
size: medium

Orange
name: orange
colour: orange
size: medium

The list of names would be apple,orange. The list of colours would be red, orange. The list of sizes would be medium. That’s it. Not medium,medium, because they’re the same thing and it can only appear in the list once. At least, that’s how Bubble normally handles it - I haven’t actually used this method to schedule API workflows before so I could be wrong, but be wary and look out for it.

Thanks I’ll have to think about this one!

The thing is I want to wait for the previous process to be fully completed before going for the next one. they will have different completion time, one could take 5 seconds, while the other could take 60s to complete. That’s why I’m trying to loop it this way and not every x seconds.

I’ve looked a bit into the bulk api, but from the docs it seems to be just a front-end api that can’t be run in the backend workflows, so won’t work in my case

No, you can run it from the backend. It’s basically an API call to your Bubble DB that behaves like a ‘Create a list of things’ action and runs straight away.

Have you considered splitting your process up?

  1. Get your list of JSON objects
  2. Process the list of JSON objects using Schedule API workflow on list
  3. When the JSON objects are all processed (using Do a search for to check they’re all created or something), schedule the next part of your logic
1 Like

Ohh I’ll have to check the bulk API again then!

Yes I was also considering splitting up the processes as you mentioned.

Many ways of accomplishing the same thing haha, but taking my time to find the most performing one :slight_smile:

Will circle back to this thread with an update or if I have more questions, you have been most helpful I really appreciate your help!