How to include the related entities to a response on a Web API «get list» request?

web-api
(Dmitry Fedyuk) #1

An example

/api/extenddforders?filter[product]=1&include=product,website

orocrm.com/documentation/2.0/book/data-api#inclusion-filter-include

Response

{
    "data": [
        {
            "type": "extenddforders",
            "id": "7",
            "attributes": {
                "date": "2016-05-10",
                "price": 89,
                "support_till": null,
                "explanation": null
            },
            "relationships": {
                "currency": {
                    "data": {
                        "type": "extenddfcurrencies",
                        "id": "1"
                    }
                },
                "product": {
                    "data": {
                        "type": "extenddfproducts",
                        "id": "1"
                    }
                },
                "website": {
                    "data": {
                        "type": "extenddfwebsites",
                        "id": "7"
                    }
                }
            }
        },
		<...>
    ],
    "included": [
        {
            "type": "extenddfproducts",
            "id": "1",
            "attributes": {
                "name_": "Stripe"
            },
            "relationships": {
                "dfProductType": {
                    "data": null
                },
                "dforder_product": {
                    "data": [
                        {
                            "type": "extenddforders",
                            "id": "7"
                        },
						<...>
                    ]
                }
            }
        },
        {
            "type": "extenddfwebsites",
            "id": "7",
            "attributes": {
                "domain": "example.com",
                "aliases": null,
                "m2_version": null,
                "m2_is_enterprise": null,
                "m2_version_url": null
            },
            "relationships": {
                "dfcustomer_websites": {
                    "data": {
                        "type": "extenddfcustomers",
                        "id": "7"
                    }
                },
                "dforder_website": {
                    "data": [
                        {
                            "type": "extenddforders",
                            "id": "7"
                        }
                    ]
                },
                "agencies": {
                    "data": []
                },
                "default_agencies": {
                    "data": null
                },
                "platform": {
                    "data": {
                        "type": "dfwebsiteplatform9e777ae8s",
                        "id": "other"
                    }
                }
            }
        },
		<...>
    ]
}
0 Likes

What is the difference between the «application/json» and «application/vnd.api+json» content types of a Web API response?
How to apply a filter to a «get list» Web API request?
The Web API documentation
(Dmitry Fedyuk) #2

See also:

0 Likes