Contact Free trial Login

Implementing Endpoints for an OData API

You can implement API endpoints such as the get:/customers:config and get:/orders:config flows using Anypoint Studio. The output format of the flows must be JSON. For more information, see the complete functioning example.

Declaring Input Variables for a GET

  1. Declare a variable for the APIkit OData Service variable that contains the fields of your entity in a list of strings (List<String>). For example:

    var entityFields = vars.odata.fields
  2. Declare a variable for the APIkit OData Service variable that filters into 'http.query.params'. For example:

    var filters = attributes.queryParams
  3. Declare a variable for the APIkit Odata Service variable that contains the keys of your entity. For example:

    var keys = vars.odata.keyNames
  4. Declare a variable for the APIkit Odata Service variable that contains the table name. For example:

    var remoteEntityName = vars.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 = vars.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 two 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.