I've faced the error 'Cannot add line items to this type of invoice' when trying to add ARInvoices->InvcDtls

Steps:

  1. Create SalesOrder by POST */Erp.BO.SalesOrderSvc/SalesOrders
  2. Create CustShips by POST */Erp.BO.CustShipSvc/CustShips
  3. Create InvcGrps by POST */Erp.BO.InvcGrpSvc/InvcGrps
  4. Create ARInvoice by POST */Erp.BO.ARInvoiceSvc/ARInvoices

The POST request that creates ARInvoice:

curl --location 'https://x/epicor11_test/api/v2/odata/x/Erp.BO.ARInvoiceSvc/ARInvoice' \
--header 'authority: x' \
--header 'accept: application/json' \
--header 'authorization: Basic x' \
--header 'x-api-key: x' \
--header 'Content-Type: application/json' \
--data '{
    "GroupID": "234231t",
    "Company": "x",
    "FiscalYear": 2024,
    "FiscalPeriod": 5,
    "FiscalCalendarID": "CompCal",
    "InvoiceDate": "2024-05-02T00:00:00-04:00",
    "InvoiceType": "SHP",
    "FOB": "Origin",
    "BillConNum": 3,
    "OrdExchangeRate": 1,
    "Plant": "X1",
    "TermsCode": "N30",
    "ReadyToCalc": true,
    "ApplyDate": "2024-05-11T00:00:00-04:00",
    "ShipDate": "2024-05-11T00:00:00-04:00",
    "CurrRateDate": "2024-05-11T00:00:00-04:00",
    "TransApplyDate": "2024-05-11T00:00:00-04:00",
    "OrderNum": 278583,
    "CustNum": 634,
    "PONum": "x",
    "SoldToCustNum": 634,
    "InvcDtls": [
        {
            "Company": "x",
            "OrderNum": 278583,
            "OrderRelNum": 1,
            "PackNum": 240891,
            "PackLine": 1,
            "InvoiceType": "SHP",
            "InvoiceLine": 1,
            "LineType": "PART",
            "UnitPrice": 1000,
            "DocUnitPrice": 1000,
            "DiscountPercent": 11.55,
            "SellingShipQty": 2,
            "PartNum": "x",
            "LineDesc": "License 100",
            "IUM": "EA",
            "DispPONum": "x"
        }
    ]
}'

Without InvcDtls it works. With InvcDtls it fails with the error: Cannot add line items to this type of invoice

How can I link the my CustShips->ShipDtls to the ARInvoice->InvcDtls by REST API?