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

Community site session details

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

Inserting Purchase Invoice Header and Multiple Lines via API

(5) ShareShare
ReportReport
Posted on by 244
Dear Techis,

I need help with inserting a Purchase Invoice Header along with multiple lines using an API.
 
I have already published the Purchase Invoice page (51, Document), and using the OData API URL, I’m able to successfully insert the header and a single purchase invoice line.
 
However, I’m encountering issues when trying to insert multiple lines using the provided payload.
 
Below are the API URL and example payload for reference.
 
Could you please suggest me on how to achieve this?
 
API URL : http://xxx:7448/BC/ODataV4/Company(xxxx')/PurchInv

Payload example

{
    "Document_Type": "Invoice",
    "Buy_from_Vendor_No": "xxx",
    "Vendor_Invoice_No": "xxx",
    "Posting_Date": "2025-03-10",
    "Purchaser_Code": "APPROVED",
    "grPurchInvPurchLines": [
        {
            "Line_No": 10000,
            "Type": "G/L Account",
            "No": "610"
        },
        {
            "Line_No": 20000,
            "Type": "G/L Account",
            "No": "612"
        }
    ]
}
 
 
Thanks in Advance!!
I have the same question (0)
  • Suggested answer
    Jainam M. Kothari Profile Picture
    14,083 Super User 2025 Season 2 on at
    Inserting Purchase Invoice Header and Multiple Lines via API
    Hello,
     
    To insert multiple lines in a Purchase Invoice using the OData API in Business Central, you need to ensure that the payload is correctly structured and that the API endpoint supports batch operations.

    Here’s a step-by-step guide to help you achieve this:
    1. Ensure Batch Operations are Enabled: Verify that your OData service supports batch operations. This allows you to send multiple requests in a single HTTP call.
    2. Modify the Payload: The payload you provided seems correct, but you need to ensure that the lines are properly nested within the header. Here’s an example of how the payload should look
    3. Use Batch Request: If your OData service supports batch requests, you can send multiple operations in a single HTTP request. Here’s an example of how to structure a batch request
    4. Check for Errors: Ensure that there are no errors in the payload structure or the API endpoint. You can use tools like Postman to test your API calls and debug any issues.
  • Gerardo Rentería García Profile Picture
    24,213 Most Valuable Professional on at
    Inserting Purchase Invoice Header and Multiple Lines via API
  • Ramesh Kumar Profile Picture
    7,523 Super User 2025 Season 2 on at
    Inserting Purchase Invoice Header and Multiple Lines via API
    Please make sure API payload are correct configured and pointed to purchase order line table not the header table.
     
     
    Thanks
    Ramesh
     
    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.
     
  • Verified answer
    YUN ZHU Profile Picture
    94,436 Super User 2025 Season 2 on at
    Inserting Purchase Invoice Header and Multiple Lines via API
  • Suggested answer
    Rajaneesh H Profile Picture
    244 on at
    Inserting Purchase Invoice Header and Multiple Lines via API
    Thank you, @YUN ZHU !! Your solution was incredibly helpful. I was able to successfully deep insert multiple lines of records into the Purchase Invoice Document. However, when I used the expand functionality to check the response for purchase invoice lines, it returned blank. Interestingly, the lines are visible in the application.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,915

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,011 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,989 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans