Nav
You are viewing an older version of this topic. To go to a different version, use the version menu at the upper-right. +

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

  1. 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']

  2. Declare a variable for the APIkit OData Service inbound property that filters into 'http.query.params'. For example:

    %var filters = inboundProperties['http.query.params']

  3. Declare a variable for the APIkit Odata Service inbound property that contains the keys of your entity. For example:

    %var keys = inboundProperties['odata.keyNames']

  4. 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

  1. Declare a variable for the APIkit Odata Service inbound property that contains the entity’s name:

    %var remoteEntityName = inboundProperties['odata.remoteEntityName']

  2. Declare a variable for transforming your payload into something like this: { myKey1: 'myValue1', myKey2: 'myValue2'}.

    %var valuesFromPayload = {
      keys: payload pluck $$,
      values: payload pluck "'$'"
    }
  3. 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'

Formatting Output

The output for each flow must conform to the following format: {"entries": [{<entry1>},{<entry2>},{<entryN>}]}

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+