%var valuesFromPayload = { keys: payload pluck $$, values: payload pluck "'$'" }
Implementing Endpoints for OData Example
Using Studio, you can implement API endpoints, such as the get:/customers:config
and get:/orders:config
flows. The output of the flows must be in JSON format. For more information, see the complete functioning example.
Declaring Input Variables for a GET
-
Declare a variable for the APIkit OData Service inbound property that contains the fields of your entity in a list of strings (List<String>). For example:
%var entityFields = inboundProperties['odata.fields']
-
Declare a variable for the APIkit OData Service inbound property that filters into 'http.query.params'. For example:
%var filters = inboundProperties['http.query.params']
-
Declare a variable for the APIkit Odata Service inbound property that contains the keys of your entity. For example:
%var keys = inboundProperties['odata.keyNames']
-
Declare a variable for the APIkit Odata Service inbound property that contains the table name. For example:
var remoteEntityName = inboundProperties['odata.remoteEntityName']
Declaring Input Variables for a POST
-
Declare a variable for the APIkit Odata Service inbound property that contains the entity’s name:
%var remoteEntityName = inboundProperties['odata.remoteEntityName']
-
Declare a variable for transforming your payload into something like this: { myKey1: 'myValue1', myKey2: 'myValue2'}.
-
Declare column and values variables, and use joinBy to transform your keys and values into comma-separated-values (CSV). For example:
%var columns = ( (valuesFromPayload.keys map "`$`" ) joinBy ", ") // myKey1, myKey2 %var values = (valuesFromPayload.values joinBy ", ") // 'myValue1', 'myValue2'