Wondering how to define object and array types for API request/response fields? Your search ends here. Explore the new feature available for API flows in IBM App Connect.

When you create Flows for an API in App Connect, you can now define object and array type properties for a resource (model) that’s suitable for your business needs. Here’s the list of data types that are supported when defining properties of a model:

  • Simple types: string, date, number, and Boolean
  • Array types: an array of strings, an array of dates, an array of numbers, an array of Boolean values, and an array of objects
  • Complex type: object (containing n-level child properties that can be simple, array, or complex types)

Let’s work through a simple flow design, which demonstrates how we can map fields of different types in the model to connector node fields by using the mapper tool.

Scenario

Create a flow for an API that allows the API consumer to create a task in Insightly when the API is invoked with event info. The task could be a generic task to notify customers about new product offers. Note that this use case interacts with Insightly only.

We first create an API with the model name Event, then define properties that make up the model.

A screenshot showing the properties for the Event model
Event model definition

We then define a create (POST) operation on the Event model, and implement a flow, where we add an Insightly “Create task” action and map the required fields by using the mapper tool.

Screenshot that shows the mapping of request body parameters to Insightly
Mapping API request properties with the mapper tool during flow authoring

The final step is to download the Swagger file from the Manage tab and invoke the API.

Screenshot of a Swagger file with a sample payload structure
Swagger with sample payload structure

Considerations:

  • Only top-level properties of a model that are either strings or numbers can be used as the ID field.
  • If you delete a parent property with a type of “object”, the defined child fields are also deleted.

For more information, see How to create an API flow in IBM App Connect.

Join The Discussion

Your email address will not be published. Required fields are marked *