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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

SalesInvoiceLines not being created when using the API

(0) ShareShare
ReportReport
Posted on by 2
Hello,
 
I have been using the Business Central API now for 2.5 years.  I built an application to sync our on-premise inventory system with Business Central.  These POST API calls work fine and they have not changed since I implemented the application: customers, item categories, and items.
 
When I built the application, I used the SalesOrders endpoint and was able to submit the following JSON and it would create the Sales Order with the Sales Order Lines.
 
{    /customerId/: /{{customerId}}/,    /externalDocumentNumber/: /{{orderId}}/,    /salesperson/: /{{SalesPerson}}/,    /shippingPostalAddress/: {        /street/: /{{address1}}/,        /city/: /{{city}}/,        /state/: /{{state}}/,        /countryLetterCode/: /{{country}}/,        /postalCode/: /{{postcode}}/    },    /salesOrderLines/: [        {            /sequence/: 10000,            /itemId/: /{{line1_itemId}}/,            /quantity/: {{line1_qty}},            /shipmentDate/: /{{shipDate}}/        },        {            /sequence/: 20000,            /itemId/: /{{line2_itemId}}/,            /quantity/: {{line2_qty}},            /shipmentDate/: /{{shipDate}}/        }    ]}
 
About 6 months ago, the API started erroring and I found that the SalesOrders endpoint no longer accepted the salesOrderLines property/array.  I needed to switch the application and make multiple posts requests to the /salesInvoices({{invoice_id}})/salesInvoiceLines endpoint to get the line items to show up.
 
Sales Invoice
{    /customerId/: /{{customerId}}/,    /externalDocumentNumber/: /{{orderId}}/,    /salesperson/: /{{SalesPerson}}/,    /shippingPostalAddress/: {        /street/: /{{address1}}/,        /city/: /{{city}}/,        /state/: /{{state}}/,        /countryLetterCode/: /{{country}}/,        /postalCode/: /{{postcode}}/    }}
Sales Invoice Line 1
 
        {            /sequence/: 10000,            /itemId/: /{{line1_itemId}}/,            /quantity/: {{line1_qty}},            /shipmentDate/: /{{shipDate}}/        }
 
 
Sales Invoice Line 2
 
        {            /sequence/: 20000,            /itemId/: /{{line2_itemId}}/,            /quantity/: {{line2_qty}},            /shipmentDate/: /{{shipDate}}/        }
 
Now the sync application is intermittently failing to create the Sales Invoice Lines for a given invoice.  I looked through all of the Microsoft Business Central documentation for the Sales Invoice APIs and found that it is the same request that I am sending.  But I am getting a 400 Bad Request error.
 
I have tried both of the URLs found here: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_salesinvoiceline_create and neither work.   Both return the 400 Bad Request error.
I cannot seem to find an updated schema maps or change history notes for why the endpoints would just stop working for the Sales Invoice Lines.  I am not submitting anything fancy, just the itemId, quantity, and unitPrice.
 
This is causing a lot of delay in the accounting department.  Any help would be appreciated.
 
Thanks,
Travis
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    101,995 Super User 2026 Season 1 on at
    Hi, is this a problem when posting in Postman? It seems to be a code problem.
    In addition, please confirm the API version you are using, beta, 1.0 or 2.0. Please try to use 2.0.
     
     
    If you still can't find the cause, it is recommended to submit an SR to the Microsoft support team for them to assist in the investigation.
     
     
    Hope this helps.
    Thanks.
    ZHU
  • TG-27040918-0 Profile Picture
    2 on at
    Hi Yun Zhu,
     
    I am use Postman to figure out and troubleshoot the API endpoint and request related issues.  I use the RestSharp or HttpClient libraries to make the API calls from within C# application.  I have used Visual Studio to debug the code, but all I get is a 400 Bad Request error from both Postman and the C# in debug mode.  So I am not sure what is wrong with the request or where to start looking for a more detailed error message.  Did the endpoint change recently and the documentation has not been updated?
     
    Thanks,
    Travis

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,371 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,806 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,371

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans