Forum Academy Marketplace Showcase Pricing Features

Import multiple users via API

I’m building something to learn the API connector. I want it to import users dynamically. The data comes from https://randomuser.me/

I tested it in Postman and I am able to make a request and get a list of generated users.
In bubble it works perfectly and I can match the user fields.

I can “create a user for someone” in the workflow. When I implement this, only the first returned record is imported.

Anyone have any suggestions before I start to hack my way through it?

Anyone try this?

Some options…

  1. For small numbers, a separate workflow action for each user to create, and specify the item # in the list.
  2. Assuming running from a client action, implement a loop, for example on a timer and a countdown of item number. Bubble deliberately makes this not obvious, to avoid certain problems.
  3. Assuming you have a paid account, could do Schedule API Workflow on a list.

How did your hacking go? : )

ooof. not so good.

I have 2 fields and a button. First is a dropdown that allows a gender to be chosen. Second is a slider to determine how many users should be imported. Finally a Create button that triggers the workflow.

This will return a list of users. Each user will have 8-10 meta. First name, Address, profile picture, etc. email and password are returned so I can directly create the user.

If I limit it to a run of 5 at a time, would the workflow be as follows?

on-click of create:

  • get the :first item on the returned list, and create that the user
  • set a timer for 1 second
  • get the second item on the list and create user.
  • rinse, lather, repeat

Would it be better to base the condition on number of returns? ie.

  • get count of return (less than 5 in this case) and run the action that specific number of times?
    or
  • create this homemade loop to test for null?

@mishav thanks for the help and wisdom!

For only 5, I wouldn’t even bother with a loop. Workflow actions:

  • call Custom Event, parameter list item 1, conditionally if item 1 not empty
  • call Custom Event, parameter list item 2, conditionally if item 2 not empty
  • call Custom Event, parameter list item 3, conditionally if item 3 not empty
  • call Custom Event, parameter list item 4, conditionally if item 4 not empty
  • call Custom Event, parameter list item 5, conditionally if item 5 not empty

Then on the Custom event:

  • Create user
  • Create other records for the user

If you do go with a loop, you’d be looking for the Do when condition is true event. A number custom state is handy for decrementing or incrementing a counter. And yes you can have more than one test, to exit the loop early.

So simple when a genius explains it. Thanks @mishav!