API problem

Database & APIs

In a JSON:API response, the user needs to extract additional data from the included section based on the IDs found in the data section.

**Description:**

When making a GET request, the user receives a response that includes primary data in the data section and additional data in the included section. The primary data contains IDs for items like branch_id, partner_id, and order_line, but does not directly include the names of these items. Therefore, the user needs to look up these IDs in the included section to get the names and other details.

**Details:**

1. **Primary Data (`data`):**

- Contains the branch_id (branch ID), partner_id (partner ID), and order_line (order line ID).

2. **Included Data:**

- Contains additional details such as branch names, partner names, and order line details that can be accessed using the IDs from the primary data.

**Required Steps:**

- Use the IDs from the primary data (such as branch_id) to search within the included section.

- Extract and display additional details like the branch name based on these IDs.

{

    "meta": {

        "version": "1.1",

        "author-info": {

            "author": false,

            "author-email": false

        },

        "documentation-link": false

    },

    "data": [

        {

            "type": "sale.order",

            "id": 2,

            "attributes": {

                "name": " So/2024/0001"

            },

            "relationships": {

                "branch_id": {

                    "links": {

                        "self": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order/2/relationships/branch_id",

                        "related": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order/2/branch_id",

                        "describedby": false

                    },

                    "data": {

                        "type": "res.branch",

                        "id": 1

                    }

                },

                "partner_id": {

                    "links": {

                        "self": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order/2/relationships/partner_id",

                        "related": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order/2/partner_id",

                        "describedby": false

                    },

                    "data": {

                        "type": "res.partner",

                        "id": 99

                    }

                },

                "order_line": {

                    "links": {

                        "self": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order/2/relationships/order_line",

                        "related": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order/2/order_line",

                        "describedby": false

                    },

                    "data": [

                        {

                            "type": "sale.order.line",

                            "id": 3

                        }

                    ]

                }

            },

            "links": {

                "self": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order/2"

            }

        }

    ],

    "included": [

        {

            "type": "res.branch",

            "id": 1,

            "attributes": {

                "name": "SAME"

            },

            "relationships": {},

            "links": {

                "self": "https://mohamed355-cata-fainal.odoo.com/adam/res.branch/1"

            }

        },

        {

            "type": "res.partner",

            "id": 99,

            "attributes": {

                "name": "ALI (STK)"

            },

            "relationships": {},

            "links": {

                "self": "https://mohamed355-cata-fainal.odoo.com/adam/res.partner/99"

            }

        },

        {

            "type": "sale.order.line",

            "id": 3,

            "attributes": {

                "name": "ECO ",

                "product_uom_qty": 1.0,

                "price_unit": 17.0,

                "price_subtotal": 17.0

            },

            "relationships": {

                "product_id": {

                    "data": {

                        "type": "product.product",

                        "id": 5928

                    }

                }

            },

            "links": {

                "self": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order.line/3"

            }

        }

    ],

    "links": {

        "self": "https://mohamed355-cata-fainal.odoo.com/adam/sale.order/2?fields[sale.order]=name,branch_id,partner_id,order_line&fields[res.branch]=name&fields[res.partner]=name&fields[sale.order.line]=product_id,name,product_uom_qty,price_unit,price_subtotal&include=branch_id,partner_id,order_line&fiter=[('is_mobile_user_sale_order','=',True)]"

    }

}

What have you tried so far?

I am new, but I tried to call, but because the data is outside, the command failed

Did you check FlutterFlow's Documentation for this topic?
Yes
1 reply