web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

API: change sale invoice lines via expand clause of the sales invoice

(0) ShareShare
ReportReport
Posted on by 35

Hi,


In order to update an invoice line via API's, you should run a PATCH command like 'PATCH businesscentralPrefix/companies({id})/salesInvoices({id})/salesInvoiceLines({salesInvoiceLineId})' as indicated via the Microsoft info: https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/api/dynamics_salesinvoiceline_update

So in this case, in order to update lines, you should make a specific request per invoice line.

In order to not make a specific request per line, I also tried to perform an update of lines via the extend clause: 'PATCH businesscentralPrefix/companies({id})/salesInvoices({id})?$expand=salesInvoiceLines', and I define the unique identifiers of the lines within the request body.

The PATCH command runs without error. But the invoice lines are not getting updated whatsoever.

Is there another possibility to update invoice lines via the PATCH URL of the sales invoice itself with a kind of expand for the lines?

  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    Best probably is to use Postman to see what is exactly happening.

    Thanks.

  • Ghetz Profile Picture
    3,029 on at

    We are testing this as well in a BC21 environment. Not sure if PATCH calls to the API support "Deep insert"; could someone confirm?

    We are calling PATCH to this URL 

    http://localhost:7048/BC210/api/v2.0/companies(cf8548d0-2167-ed11-b873-94a03e9df123)/salesOrders(0cf0f607-f5bc-ed11-b874-9a7fd23bd999)?$expand=salesOrderLines

    Request body looks like this:

    {
        "customerNumber": "CL/0000009",
        "salesOrderLines": [
            {
                "itemId": "557b9822-4d67-ed11-b873-94a03e9df999",
                "quantity": 10
            },
            {
                "itemId": "557b9822-4d67-ed11-b873-94a03e9df999",
                "quantity": 8
            }
        ]
    }

    Important to add header If-Match * , as this is a PATCH call

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 664 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 446 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 282 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans