How to request data from nested API

i’m having a bit of trouble with terraform: i have a API with a json array, the json array has the following code

[
{
“url”: “”,
“name”: “HMS Host”,
“iotCustomerId”: “Nmanueelsamimport10002684354560”,
“colibriNetworkId”: 2684354560,
“apn”: “”,
“operator”: “24007”,
“dns1”: “8.8.8.8”,
“dns2”: “8.8.4.4”
},
{
“url”: “”,
“name”: “Rijk Zwaan”,
“iotCustomerId”: “Nmanueelsamimport10003254779904”,
“colibriNetworkId”: 3254779904,
“apn”: “”,
“operator”: “24007”,
“dns1”: “10.8.100.11”,
“dns2”: “10.8.100.12”
},
{
“url”: “”,
“name”: “HPS Solutions”,
“iotCustomerId”: “Nmanueelsamimport30002801795072”,
“colibriNetworkId”: 2801795072,
“apn”: “”,
“operator”: “24007”,
“dns1”: “8.8.8.8”,
“dns2”: “8.8.4.4”
},
{
“url”: “”,
“name”: “HPS-Vitalis-T2”,
“iotCustomerId”: “Nmanueelsamimport40002818572288”,
“colibriNetworkId”: 2818572288,
“apn”: “”,
“operator”: “24007”,
“dns1”: “8.8.8.8”,
“dns2”: “8.8.4.4”
},[
{
“url”: “http://10.221.185.28:8000/v1/network/2684354560/”,
“name”: “HMS Host”,
“iotCustomerId”: “Nmanueelsamimport10002684354560”,
“colibriNetworkId”: 2684354560,
“apn”: “sam.iot-provider.com”,
“operator”: “24007”,
“dns1”: “8.8.8.8”,
“dns2”: “8.8.4.4”
}]

each object of this array has a url as its first element. this url contains another json array with the following code

{
“url”: “”,
“name”: “HMS Host”,
“iotCustomerId”: “Nmanueelsamimport10002684354560”,
“colibriNetworkId”: 2684354560,
“apn”: “”,
“operator”: “24007”,
“dns1”: “8.8.8.8”,
“dns2”: “8.8.4.4”,
“url2”: “”
}
{
“url”: “http://10.221.185.28:8000/v1/network/2684354560/ipranges/”,
“name”: “HMS Host”,
“iotCustomerId”: “Nmanueelsamimport10002684354560”,
“colibriNetworkId”: 2684354560,
“apn”: “sam.iot-provider.com”,
“operator”: “24007”,
“dns1”: “8.8.8.8”,
“dns2”: “8.8.4.4”,
“url2”: “http://10.221.185.28:8000/v1/network/2684354560/sims/
}

the first element is again a url, when using this url we get another json array with the following code

[
{
“url”: “”,
“id”: 45,
“iprange”: “100.64.1.0/24”,
“network”: “2684354560”,
“operator”: “24007”,
“type”: “static”,
“apn”: “”
}
]
[
{
“url”: “http://10.221.185.28:8000/v1/network/2684354560/ipranges/45/”,
“id”: 45,
“iprange”: “100.64.1.0/24”,
“network”: “2684354560”,
“operator”: “24007”,
“type”: “static”,
“apn”: “sam.iot-provider.com
}
]

using terraform i would like to inject the following three things in a fortigate firewall this the code i currently have

data “http” “networks” {
url = “http://10.221.185.28:8000/v1/network/
method = “GET”
}

Fetch the JSON data using HTTP data source

data “http” “network_data” {
url = “http://10.221.185.28:8000/v1/network/
}

Define a local variable to store the processed data

locals {
processed_data = jsondecode(data.http.network_data.body)
}

Iterate through the top-level array and extract relevant data

locals {
filtered_data = [for network in jsondecode(data.http.networks.body) : {
name = network.name
url = “${network.url}ipranges/”
}]
}

resource “fortios_firewall_address” “test” {
for_each = { for network in jsondecode(data.http.networks.body) : network[“name”] => [network]… }
name = each.key
}

the part i am most confused about is how to use a url i get in filtered_data and use it to make make a API call to request another object from the json array on that url and put it in the array created in the locals. i am new to therraform so feel free ta ask if i didn’t give enough information to help.