Use APIs to have the payload update entities and associations
- Last Updated: September 4, 2024
- 2 minute read
- Corticon.js
- Documentation
Corticon.js Service Callout APIs let you use payloads to add, set, and remove
associations between entities. The parameters are:
entityParent- The Entity for the associationroleName- The association roleNameentityChildren- The Entity's associationpayload- The payload as a JSONObject or JSONArray
add Entities and Associations from a payload
addEntitiesAndAssociations(entityType, payload)
To enrich the data and the working memory you can add entities and associations using this API. The entities will be added as top level entities. This api takes two parameters, the <entityType> and the <payload>. The entityType is the type of entity (defined in the vocabulary) at the root of the payload. The payload itself can either be a JSON Object or a JSONArray. If passing in a JSONObject, the entityType should match the entityType at the root of the JSONObject.
|
You can also add multiple Cargo’s to the working memory. In that case you can pass in a JSON Array of Cargo’s instead of a JSONObject:
|
Note: Make sure the payload has the JSON Overrides value . Refer to the JSON Overrides sections
here.
addAssociationsToEntity
addAssociationsToEntity(parentEntity, rolename, payload) - To
enrich the data and the working memory you can add nested associations to existing
entities using this API. The entity to which you want to add associations should be in
the working memory . The entity can be at any level in the input tree. This api takes
three parameters, the <parentEntity> the <rolename> and the <payload>. The
parentEntity is the entity in the working memory to which you want to add the
association. The rolename is the association you want to add (defined in the
vocabulary). The payload itself can either be a JSON Object or a
JSONArray. :
|
You can also add multiple nested associations to an entity. If you want to add multiple
associations to an entity, it must be supported in the vocabulary. To add multiple
associations one must pass in a JSONArray:
|