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