Convert Type to JSON in Workflow for API consumption

There are several techniques discussed already on the forum. You’d need to provide more information to work out which is appropriate.

To summarise …

  • The JSON body is a string, which you can build up with text operations.

  • If there is a single instance of the data type (not a list), or a fixed length list (example, always two items), it can be built up at the time of the API call.

  • If there is a variable length list of the data type, there are two alternatives:

  • Build up each item’s JSON structure as it is created or modified, and store it in the database. Then at the time of the API call, retrieve the list of JSON objects and join them together into a JSON array.

  • Use the List Item Expression to build the entire JSON array at once. This only works on the client, so if your API call is happening from an API workflow triggered outside of Bubble, it would need to be done earlier by a client operation, and stored somewhere, i.e. similar to the first alternative.

1 Like