How to save api response in database in the right format

The api I am using produces output in a format (a list of dictionaries) so it looks like the following:

response = [
{‘Q’: ‘What is 2 x2’, ‘A’: 4},
{‘Q’: ‘What is 3 x2’, ‘A’: 6}
]

Anyways, I’m then struggling to save these as independent questions and answers in the database - as of right now, it saves all the questions in one string, and all the answers in another string.

Does anyone know how to save each item as a separate line item in the database? So the following would add 2 rows to my database.

Thanks!

This is not a dictionnaries.
you basically have two keys: Q and A.
If you want to process everything line by line, you will need to use a Backend Workflow and Schedule on a list

1 Like

Do you have any references for me to learn how to do this?

Not really but pretty sure you can find some topic here. @cmarchan may also know a few ressource.
The first thing is that you need to set your API call as a DATA type and not ACTION.
Then you can Create a backend WF that will have two fields: question (text) and answer (text),
In a workflow on a page, you can Schedule API WF on a list. You select the list from the API Connector data type. You fill the fields with something like This list’s Q an This list’s A. In the backend WF, you set an action to create an item with the Q and A field.

2 Likes

Thanks!!

1 Like

Hi @sohaibwork ,

These are two interesting videos that could be helpful

Hope this helps :+1:t2: