Help with adding data from external API to state

  1. I am successfully pulling in data from an API into a Repeating Group:

  2. I’ve made sure the groups under the RG all have the correct source data:

  3. I’ve added a button (‘DRAFT’ - pictured) in said Group, and what I would like to do is add a workflow that adds that cell’s name into a state. However when I try and add this to the workflow, I get this error:

“Value should be a list of players but right now it is a text”

I’ve been going crazy looking at this problem for days - I know its probably related to me needing to reconcile the data with my data type ‘Player’ but I can’t seem to find out how to do this. Feels like I’m missing a step. Any help would really be appreciated!

Which type is your state? Is it a type from API? Can you sahre API payload.example?

Set your state to type text

The state type is ‘Player’ (list):
Screenshot 2024-05-14 at 10.18.02 PM

The field I’m trying to pull in is a player name (so its type text):
Screenshot 2024-05-14 at 10.18.52 PM

@yamada.shoji99 if i set the state to type text, will i still be able to save it into my data base? I have a ‘Player’ data type and a ‘Team’ data type. A team is made up of a list of these players.

You cannot use a DB type for an API type. If you need a player name, this is a text, and list should be of type text. If you want to a cell of your RG, you need to set the state in the same type of your RG. Because current cell is of type RG data source. You can aave this to your DB with the value of this object.

Yes you can, create new thing then save the data e.g. Player = your state name

Thank you both! I refactored everything to change the states to a ‘Text’ and it seems to be working so far.

1 Like

One quick follow up question -

I am trying to create a ‘My team’ group that displays a user’s drafted players:

However, what I’d like to do is categorize it based on the player’s Position (field of the Player data type). For example, I want all the QBs drafted to be categorized together, all the RBs together, etc.

I’m struggling on how to do this since when I set the State, it only pulls in the player’s NAME (and not position). I’ve tried creating a separate repeating group with the state as a data source (failed), and several other methods with no luck. Any idea @Jici @yamada.shoji99, or anyone else? I feel very close but just can’t seem to crack the nut.

I just tried making a conditional statement as well in an RG that pulls from the API data source, but it just shows every entry: