# Add rows in a table based on json coming from a api call

**URL:** https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429
**Category:** Ask for Help
**Created:** [October 31, 2023, 8:58pm UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429 "2023-10-31T20:58:41Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)
#### Post date: [October 31, 2023, 8:58pm UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/1 "2023-10-31T20:58:41Z")

</div>

I’m trying to find the right solution for this use case.  
Data about a company and its board members can be found by use of “call api” to a specific endpoint.

The resulting json has a structure like  
company  
– company\_number : 100  
– board  
— boardmember  
----- Name: John Doe  
----- Address: The earth  
— boardmember  
----- Name: Alex Johnson  
----- Address: The moon

I would like to let the users manually add position to the board members - therefore I’m thinking of putting all the boardmembers into a new table like

```auto
| Name | Address | Position |
|--------------|-----------|----------|
| John Doe | The earth | CEO |
| Alex Johnson | The moon | CFO |

```

I would then be able to show all the boardmembers in a collection (and filter by company\_number)

When the Positions has been added to the boardmembers by the user then I expect that I would write all the data to new table with all boardmembers for all companies whereas the table shown above should be a helper table. But this is potentially just a bad idea that complicates the setup unnecessarily as I don’t really see an easy way to add multiple rows in a new table.

How would you solve such a case? Any ideas? Will I need to introduce [Make.com](http://Make.com) (I would actually love to it all in Glide)

_NB: this must be done (automated) for multiple companies_

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [November 1, 2023, 12:12am UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/2 "2023-11-01T00:12:33Z")

</div>

I think adding rows in a new table is the right approach.

The only way I can think of to do it solely in Glide requires using the Call API action.

- Write a JavaScript function to work with the original JSON, which will output multiple mutations that can be used in the Call API action.

- Trigger the Call API action with the mutations.

If you don’t have access to Call API, probably [Make.com](http://Make.com) is the way to go, with the same approach of creating multiple mutations (through an iteration) and then use a single HTTP module to add multiple rows.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [November 1, 2023, 12:15am UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/3 "2023-11-01T00:15:50Z")

</div>

Yes, @ThinhDinh is correct. Build a payload in your Helper Table to add the new rows and use the Call API action to add them. It’s actually fairly straight forward, I’ve been doing it for a while.

---

<div class="post-metadata">

### Author: ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)
#### Post date: [November 1, 2023, 7:30am UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/4 "2023-11-01T07:30:30Z")

</div>

@Darren_Murphy @ThinhDinh Thanks a lot for your input.  
I admit this is not easy for me to do as I can probably only at my best can adjust some existing javascript to do something similar.

As you have done it before, Darren, would you be able do a small example to show how this is actually done? I think that it is a pattern that would be great for others to understand: Based on json data in one cell how can you create multiple rows in another table.

Would be so much appriciated 🙂

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [November 1, 2023, 7:35am UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/5 "2023-11-01T07:35:41Z")

</div>

Here are a couple of Loom videos that I made a few months back. These demonstrate setting values in multiple rows, but the same technique can be applied to add rows.

The first video uses templates and joined lists. The second one uses the new JSON Columns.

I guess what isn’t covered in the above is how you would transform an API JSON response into something you could feed into the API call to add new rows. It’s kind difficult to show something generic for that as every situation will be slightly different.

---

<div class="post-metadata">

### Author: ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)
#### Post date: [November 4, 2023, 2:42pm UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/6 "2023-11-04T14:42:53Z")

</div>

@Darren_Murphy Thanks you showing a way.  
I have a question - from where did you get _JSON array_ column. Doesn’t seem to be there for me.  
1:31 into second video

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [November 4, 2023, 2:59pm UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/7 "2023-11-04T14:59:47Z")

</div>

ah yes, that column has been deprecated since I made that video, and the JSON Object column now handles arrays.

---

<div class="post-metadata">

### Author: ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)
#### Post date: [November 4, 2023, 4:09pm UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/8 "2023-11-04T16:09:07Z")

</div>

@Darren_Murphy  
Another question in relation to using **Call API**

I use a Query JSON column - and it results in a mutations array of _one_ element - and therefore start bracket [and end bracket] are missing.

And I therefore get a bad request when I do a Call API.

Is this really to be expected even when the JSON is valid?

> {  
> “appID”: “eBrEBeungKTfhE4UijRR”,  
> “mutations”: {  
> “kind”: “add-row-to-table”,  
> “tableName”: “native-table-ujUoRWQ0TSOEAsrbpXGd”,  
> “columnValues”: {  
> “UYJya”: “CVR-3-4004007869”,  
> “zv7Ts”: “A V”,  
> “9iUYf”: “Direktion”,  
> “tkABp”: “KV”,  
> “M7jF4”: “Mr”,  
> “tulMY”: 12345678,  
> “xXF5I”: “ABC-1-12345678”,  
> “fRlqc”: “”,  
> “ZtH4N”: “ddd”  
> }

The definition of a request to add-rows

> curl --request POST ‘[https://api.glideapp.io/api/function/mutateTables](https://api.glideapp.io/api/function/mutateTables)’   
> –header ‘Content-Type: application/json’   
> –header ‘Authorization: Bearer \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*’   
> –data-raw ‘{  
> “appID”: “eDDDDeungDDfhD4DijDD”,  
> “mutations”: **[**  
> {  
> “kind”: “add-row-to-table”,  
> “tableName”: “native-table-ujDoDDDDTSOEAsrbpXGd”,  
> “columnValues”: {  
> “tkABp”: “Kilde”,  
> “UYJya”: “PersonLassoId”,  
> “zv7Ts”: “Navn”,  
> “9iUYf”: “RolleType”,  
> “M7jF4”: “Rolle”,  
> “xXF5I”: “VirkLassoId”,  
> “tulMY”: “CVR”,  
> “fRlqc”: “Adresse1”,  
> “ZtH4N”: “Adresse2”  
> }  
> }  
> **]**  
> }’

> }  
> }

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [November 4, 2023, 4:18pm UTC](https://community.glideapps.com/t/add-rows-in-a-table-based-on-json-coming-from-a-api-call/67429/9 "2023-11-04T16:18:51Z")

</div>

Mutations should be an array (square brackets `[]`)
