REST - JSON Arrays (Drill Downs)¶
REST – JSON Arrays¶
- Vinyl can send complex JSON Arrays
- Makes use of a new option: 'Drill Down'
- Specify drill down table from the root API Call
- And work your way down the JSON structure
JSON Arrays - GET Example¶
Customer has multiple addresses.¶
Example record from the Customer table of a Customer with an ID, Name, and an array of 2 Addresses:
On the REST side, if we were to GET from that table it would create:
-
A Root table where the ID and Name are:
-
An Address table with 2 records:
JSON Arrays - POST Example¶
Local Customer record that I'd like to POST.¶
-
A simple Customer table with 1 record that contains an ID and Name:
-
An Address table with 2 records that are both linked to that Customer record by the CustomerID:
JSON Arrays - POST Endpoint¶
Set up our POST endpoint as usual.¶
- For this example we have provided some sample JSON, which includes our record and our address tables
- This generates the Tables for the REST Endpoint
Note
Request Body is only available for POST Endpoint, not GET Endpoint.
JSON Arrays - API Call¶
Top level API Call rule.¶
- This rule is inserting the
CustomerID
and theName
- It is targeting the root table, which is
customers (post)
- It is selecting
id
andname
from theCustomerTest
table
JSON Arrays - API Call¶
Address API Call rule.¶
- This rule is inserting into
customers (post)/addresses
- It is selecting the Address and ID info from the
CustomerAddressTest
table
JSON Arrays - Drill Down¶
Select address as a 'Drill Down' on top level API Call (Edge Case Settings)¶
- Now that we have set up those two API Call rules we can tie them together
-
On the root API Call rule there is an Advanced Setting option called Drill Downs
-
This allows us to specify sub-rules to run
- In this case, we call
Customer_Address_POST
, which writes into that Address REST Endpoint table -
We also configure the Binding
JSON Arrays - Result¶
- Success!
- This works with multiple nested tables too
-
Supports simple arrays as well
- Edge Case Setting on REST Endpoint table
- "Array Of Primitives"