Includes
Fetching Included Resources
Using the "includes" parameter, you can retrieve additional related resources, such as:
- Cart items for carts
- Categories for products
- Options for option groups
The "includes" query parameter you choose depends on the API endpoint you are using. You can use multiple values; for example /products?includes=prices&includes=categories
.
Note
There is no limit to the number of included resources per request; however, including too many resources can negatively impact performance. If the resource may contain more than 100 included records, make separate API calls.
Each supported resource includes its own documentation on available resources that can be included. If you request a resource to be included but no related records of that resource type exist, the response will contain an empty included section.
Similarly, if you request a resource that the endpoint does not supported, that section will not be included, but you will still receive a 2xx
response.
Creating Included Resources
In addition to fetching relational data, the same data can be created in a single API call in conjunction with its parent data. For example, creating products and their related prices can be done in a single POST request.
Example: Create Products and Prices
In the following example, we create a product and its related prices.
curl --request POST \
--url https://rlp-dev.congacloud.io/api/catalog/v1/products \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
[
{
"ConfigurationType": "Standalone",
"ExcludeFromSitemap": false,
"HasAttributes": false,
"HasDefaults": false,
"HasOptions": false,
"HasSearchAttributes": false,
"IsActive": false,
"IsCustomizable": false,
"IsTabViewEnabled": false,
"Uom": "Each",
"Name": "Example Product",
"Prices" : [
{
ListPrice : 100,
"PriceList": {
"Id": "38a5a5bb-dc30-49a2-b175-1de0d1488c43",
"Name": "Example Price List"
}
}
]
}
]
'
Example: Create a Constraint Rule with Actions and Conditions
In the following example, we create a constraint rule with its associated conditions and actions.
curl --request POST \
--url https://rlp-dev.congacloud.io/api/configuration/v1/constraint-rules \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
[
{
"IsActive": false,
"IsBundleContext": false,
"Name": "Example Constraint Rule",
"Actions" : [
{
"ActionType": "Inclusion",
"IsAutoExclude": false,
"MatchInAsset": false,
"MatchInCartOptions": false,
"MatchInOptions": false,
"MatchInPrimaryLines": false,
"IsRepeatInclusion": false
}
],
"Conditions" : [
{
"MatchInCartOptions": false,
"MatchInLocation": false,
"MatchInOptions": false,
"MatchInPrimaryLines": false,
"MatchInRelatedLines": false,
"MatchInServiceAssets": false
}
]
}
]
'
Updated 12 months ago