
We have a web service that returns data in the following schema:
"type": "object",
"properties": {
"total": {
"type": "integer"
},
"per_page": {
"type": "integer"
},
"current_page": {
"type": "integer"
},
"last_page": {
"type": "integer"
},
"next_page_url": {},
"prev_page_url": {},
"from": {
"type": "integer"
},
"to": {
"type": "integer"
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"transferred_at": {
"type": "string"
},
"est_departed_at": {
"type": "string"
},
"est_arrival_at": {
"type": "string"
},
"inventory_transfer_items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"description": {
"type": "string"
},
"qty": {
"type": "string"
},
"price": {
"type": "string"
},
"uom": {
"type": "string"
},
"received_at": {
"type": "string"
},
"received_qty": {
"type": "string"
},
"inventory_type": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"net_weight": {
"type": "string"
},
"packed_qty": {
"type": "string"
},
"cost": {
"type": "string"
},
"uom": {
"type": "string"
}
}
}
},
"required": [
"created_at",
"updated_at",
"description",
"qty",
"price",
"uom",
"received_at",
"received_qty",
"inventory_name",
"strain_name",
"inventory_type"
]
}
}
},
"required": [
"created_at",
"updated_at",
"transferred_at",
"est_departed_at",
"est_arrival_at",
"inventory_transfer_items"
]
}
}
}
}Note there are two nested arrays in the return body - "inventory_transfer_items" and "inventory_type".
How do I access the inner arrays within PowerApps? The top level array "data" is no problem - but the next inner array "inventory_transfer_items" shows up as type object. I can't access the elements of "inventory_transfer_items" either.
I want to store the results in a PowerApps collection. Thanks for your help!
Hi @tbelvin ,
The Schema you provided shows that the type of inventory_transfer_items seems to be array, and the inventory_type seems to be object.
You could try to parse the return body directly using Parse JSON action.
I did a test on my side, configured the Schema you provided in Parse JSON, and then traversed the elements in data in Apply to each.
Traverse the elements in inventory_transfer_items in Apply to each 2.
There are a lot of properties with the same name when using Dynamic content contained in Parse JSON. You could see which Apply to each is included.
For example, there are three Created_at, if it is items(‘Apply_to_each’)[‘created_at’], it means that it is an property in the element contained in data.
If it is items(‘Apply_to_each_2’)[‘created_at’], it is an property in the element contained in inventory_transfer_items.
If it is items(‘Apply_to_each_2’)[‘ inventory_type’][‘created_at’], it is an property contained in inventory_type.
Image reference:
Hope it helps.
Best Regards,