Adding response and request parameters of the collection type
Collection (or array) is a set of items. There are two types of collection parameters:
-
Simple collection. Any parameter can be made a collection by selecting the [Is array] checkbox. Simple collections are arrays of values of the same data type, each value being a separate collection item. For example, “1, 2, 3" is a simple array of integer values, “Boston, New York, Chicago” - is a simple array of text values, etc.
-
Object collection. To add this type of collection, select “Object” in the [Data type] field of the request or response parameter. Each item in an “Object” collection can have a set of parameters of different type. These collection item parameters are represented as nested parameters of the parent collection parameter. For example, an array of contacts can have nested parameters for contact name, date of birth and age (Fig. 1).
An actual collection of such a structure would look like this:
Contact name | Date of birth | Age |
Jane Barber | 04/12/1991 | 27 |
Aaron Shepard | 10/24/1985 | 33 |
Kate Smith | 12/05/1989 | 29 |
Creatio can pass collections in web service requests and parse web service responses that contain collections. You can set up both request and response “collection” parameters, provided the web service supports receiving and/or sending arrays.
Note
You can only select the “collection” data type for parameters of the “Body parameter” type. This type of parameters is not available for GET requests. However, it is available for GET responses.
To add a response or request “collection” parameter with nested parameters:
1.Click [Add parameter] on the [Request parameters] or [Response parameters] tab.
2.Select the “Object” value in the [Data type] field.
3.Add nested parameters of the needed type to this collection by clicking the [Add parameter] button and selecting the [Add nested parameter] option (Fig. 2).
For example, the response collection parameter that gets the contact records from the server will look as follows (Fig. 3):
The value of the JSONPath for the nested parameters is specified as suffix of the JSONPath of the root parameter. For example, if the root parameter has the“$.records”value in the JSONPath field and the “$.records.name” value should be specified for the “Name” nested parameter, you need to specify only the “name” value in the “Path to element” field.
Web service response parameters of the collection type can be used as incoming parameters in the “Call web service” business process element. More information about using collections in business processes can be found in the article.
See also