Getting entity and aggregate values by using the REST API
You can retrieve information about entities and aggregates in a solution by making REST API calls.
Before you begin
Set up role-based access control to the REST API commands and review the REST API reference topics.
About this task
Because you can use a browser to call REST API methods, getting values is useful for testing. For example, you can check in a browser whether an entity is created or verify the current value of a global aggregate.
Procedure
- To retrieve an entity value, enter a GET request in the
following form:
For example, the following request uses the regex parameter and returns a range of CustomerID entities that are in the BankingSolution business model definition:https://localhost:port/ibm/ia/rest/solutions/solution_name/entity-types/entity_type/entities/entity_idhttps://localhost:9443/ibm/ia/rest/solutions/BankingSolution/entity-types/CustomerID/entities/?regex=id[200-205] - To retrieve the value of a shared aggregate, enter a GET request in the following form:
For example, the following request returns the value of the DepositCount shared aggregate in BankingSolution:https://localhost:port/ibm/ia/rest/solutions/solution_name/entity-types/entity_type/entities/entity_id/aggregate/shared_aggregate_namehttps://localhost:9443/ibm/ia/rest/solutions/BankingSolution/entity-types/Customer/entities/GoldCustomer/aggregate/DepositCount - To retrieve a global aggregate value, enter a GET request
in the following form:
https://localhost:port/ibm/ia/rest/solutions/solution_name/aggregate/aggregate_nameYou must include the defvar prefix in the name of the global aggregate.
If you omit aggregate_name, all the global aggregates in the solution are returned.
For example, the following request returns the current value of the MaxDeposit global aggregate in BankingSolution:https://localhost:9443/ibm/ia/rest/solutions/BankingSolution/aggregate/defvarMaxDeposit - To retrieve the value of a grouped by shared aggregate, enter a GET request in the following
form:
For example, the following request returns the value of the depositsByBank shared aggregate that is grouped by bank, which is a type of entity defined in the business model definition of BankingSolution:https://localhost:port/ibm/ia/rest/solutions/solution_name/entity-types/entity_type/entities/entity_id/aggregate/shared_aggregate_name?groupBy=valuehttps://localhost:9443/ibm/ia/rest/solutions/BankingSolution/entity-types/Customer/entities/GoldCustomer/aggregate/depositsByBank?groupBy=Bank0735The shared characteristic by which events are grouped must be based on one of the following value types: integer, string, enumeration, absolute duration, year, month of year, day of week, day of month, hour of day, minute of hour, second of minute, time of day, character, or entity.
Tip:When you use an enumeration, the enumeration value must be written as it is defined in the business model. An absolute duration must use the ISO_8601 standard, for examplegroupBy=PT30M.
A month of year groupBy type is in the range 1-12 for each month, where 1 is equal to January.
For a day of the week, groupBy can be the textual name in English or an integer value. The integer value follows the ISO-8601 standard, from 1 (Monday) to 7 (Sunday). In the following example, the value is returned by all of the requests:
https://localhost:9443/ibm/ia/rest/solutions/PizzaDelivery/entity-types/pizza.Customer/entities/Smith/aggregate/monthlyPurchasePrice?groupBy=4 https://localhost:9443/ibm/ia/rest/solutions/PizzaDelivery/entity-types/pizza.Customer/entities/Smith/aggregate/monthlyPurchasePrice?groupBy=thursday https://localhost:9443/ibm/ia/rest/solutions/PizzaDelivery/entity-types/pizza.Customer/entities/Smith/aggregate/monthlyPurchasePrice?groupBy=THURSDAYFor a time of day, the value must be encoded. The following example groupBy=04%3A24%3A50 is equivalent to 04:24:50 a.m. An entity value must use the entity identifier, for example groupBy=entityId.