'How to create multiple entities using a single OData POST to a Business Central Web Service?

I tried to POST an array of objects and, as expected, it isn't that easy. In my case I want to insert multiple Transfer Order Lines in the same request.

// Request Body
[
    {
        "documentNo": "1002",
        "itemNo": "1968-S",
        "quantity": 3
    },
    {
        "documentNo": "1002",
        "itemNo": "1968-S",
        "quantity": 113
    }
]

// Response
{
    "error": {
        "code": "BadRequest",
        "message": "Invalid Request Body  CorrelationId:  a2606676-3f8f-4753-aaee-be91a621f070."
    }
}

Is it possible to do what I want without sending a request for every Line entity I want to add?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source