OCAPI Filtering

After you specify a resource type and relationship type (see URL schema), you can specify a filter parameter to further reduce the number of resource instances in the result set. Filter parameters differ for each resource_type and relationship_type pair. In the following example, the first filter parameter type specifies a value of cross_sell, eliminating from the result set all resource instances whose type isn’t equal to cross_sell. The second filter parameter direction specifies the value out, eliminating all resource instances whose direction is different.

1REQUEST:
2GET /dw/shop/v24_5/products/123/links?type=cross_sell&direction=out HTTP/1.1
3Host: example.com
4Accept: application/json
5
6RESPONSE:
7HTTP/1.1 200 OK
8Content-Length: 351
9Content-Type: application/json; charset=UTF-8
10
11{
12  "_v" : "24.5",
13  ...
14  "product_links":
15  [{
16    "source_product_id":"123",
17    "source_product_link":"http://example.com/dw/shop/v24_5/product/123",
18    "target_product_id":"456",
19    "target_product_link":"http://example.com/dw/shop/v24_5/product/456",
20    "type":"cross_sell",
21    "direction":"out"
22  },
23  {
24    "source_product_id":"123",
25    "source_product_link":"http://example.com/dw/shop/v24_5/product/123",
26    "target_product_id":"789",
27    "target_product_link":"http://example.com/dw/shop/v24_5/product/789",
28    "type":"cross_sell",
29    "direction":"out"
30  }]

Attention!

The Open Commerce API (OCAPI) is now deprecated. The provisions described in our versioning and deprecation policy fully apply. For all new projects and major refactoring work, use B2C Commerce API (SCAPI) as the default REST API. For additional details, refer to Why Use SCAPI Instead of OCAPI.

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!