Workflow-REST API data to Retool Database

-Goal: REST API response data to Retool Datasbase using workflow.
-Steps:

  1. Created a new workflow, added a trigger to run everyday.
  2. Added REST API resource component and using POST method to fetch the data from the API.
  3. Created a table in Retool Database manually as per API response.
  4. Ran the API component and fetched the data.
  5. Trying to parse the above response data and store into the table created in Retool Database using JS/Python, but it is not working. Find below the screenshot:

Can anyone please help me here. Much Appreciated!
Thanks.

Hello @sidharth1995!

My best guess based on what I see here is that you have an invoice in your apiData array that does not have the InvoiceInfo property (or is null) or there isn't an array stored in the Detail property (or it is null)

I noticed you built in a check for null Invoice data, so you might want to try to error catch these other properties the same way.

Can you use a code block just to return the Invoice data to see if there is anything that jumps out at you in the data's properties?

Hi @pyrrho, thanks for your advise.

I have tried to just return the Invoice data. How to flatten InvoiceInfo and other fields containing sub fields? See below:

Thanks!

@sidharth1995 If you want to return an array of a property with sub-properties I usually do it this way:

{{formatDataAsObject(query1.data.Invoice).InvoiceInfo}}

This should return an array of just the one property called out after converting your query data to an object.

1 Like