Xero API - Displaying contacts in a table

Hi!

I'm currently working to integrate the XERO accounting API with a retool application.

I am connected to the API no problem and have been able to obtain the JSON response .. now I have hit a wall after reading what feels like hundreds of tutorials and pages of documentation.

Here is an example of the API response I am getting...

{
"Id": "e936038d-XXXX-XXXX-XXXX-XXXb1aX24",
"Status": "OK",
"ProviderName": "Retool Test",
"DateTimeUTC": "/Date(1673515441963)/",
"Contacts": [
{
"ContactID": "d99a9b6c-XXXX-XXXX-XXXX-0cd8cbb6fffe",
"ContactStatus": "ACTIVE",
"Name": "Global Sports ",
"FirstName": "John",
"LastName": "Doe",
"EmailAddress": "john@doe.co.uk",
"BankAccountDetails": "",
"Phones": "",
"UpdatedDateUTC": "/Date(1508164036277+0000)/",
"ContactPersons": [],
"HasAttachments": false,
"HasValidationErrors": false
},
{
"ContactID": "d99a9b6c-XXXX-XXXX-XXXX-0cd8cbb6fffe",
"ContactStatus": "ACTIVE",
"Name": "Social Activator ",
"FirstName": "Jane",
"LastName": "Doe",
"EmailAddress": "jane@doe.co.uk",
"BankAccountDetails": "",
"Phones": "",
"UpdatedDateUTC": "/Date(1508164036277+0000)/",
"ContactPersons": [],
"HasAttachments": false,
"HasValidationErrors": false
}
]
}

I am desperately trying to display the data in a simple table that has a row for each contact and shows the 'ContactID' and 'Name' field.

All my previous development experience has been basic PHP so it's taking me a while to get my head around Javascript transformers etc.

Any suggestions would be appreciated!

Many thanks!

What you can do is format the data in a transformer in the query panel using
return formatDataAsArray(data)

then in the table Inspect panel in the Data field add
{{yourqueryname.data['0'].Contacts}}
There are also other ways of handling this using mapping if you search in the forum...

:thinking: it looks like the Contacts property is already formatted as an array so you may also be able to use yourqueryname.data.Contacts without any additional transformers. Were you able to get the correct syntax here @sewsewsimon?