Dynamics 365 Business Central API's - PUT/PATCH Header with Detail Lines

daans
Member Posts: 21
Hi,
We're currently writing an integration to synchronize Orders and Order Lines between 2 Business Central databases using API's. (Note: we're talking about a custom Order/Order Line implementation, but it's quite similar to a standard Sales Order)
At this point I'm able to create a new Order with Lines using a single http POST call.
In some cases our integration requires an update of the Order and its lines. These are the steps we're trying to perform to achieve this
- STEP 1:Delete the existing Order Lines using a Bound Action of the Order Entity API
- STEP 2: Update the Order and the Lines using a PUT (or PATCH) http call using the eTag of the Order (See request below)
We're noticing that only the Order is updated in STEP 2, the Order Lines remain untouched (even if STEP 1 is skipped). This seems somewhat logic since Order and Order Lines have a different eTag and the eTag is used to determine if the record was already updated or not.
Is there a way to update an Order and add Order Lines in a single API call? In our case, an Order can contain quite some Order Lines. This will result - in case of an update - in a huge amount of API calls.
PUT http://mydomain.com/orders('myorderno') HTTP/1.1 Authorization: Basic eW91bmdwYXJ0bmVyc1xkc2FuOkF6ZXJ0eTEyMzQh Accept: */* Cache-Control: no-cache If-Match: W/"JzQ0OzRHU3plSVV0V2p0Y2pBeW1nUnJFeDFiaUtPQUZXR0Z6cEYvZHNPWDl0cTA9MTswMDsn" Content-Type: application/json Host: mydomain:7058 Content-Length: 553 Expect: 100-continue { "externalOrderType":"", "externalOrderCode":"TTR-9001136|10000|30000", "orderType":"Out", "orderDate":"2019-11-01", "terminal":"ADR-0005862", "principalCode":"", "principalReference":"TTR-9001136", "vehicleCode":"", "trailerCode":"", "driverCode":"", "subcontractorCode":"", "subcontractorName":"", "enforceLoadSequence":false, "orderLines":[ { orderNo:"myorderno", orderLineNo:0, "orderDate":"2019-11-01", "externalParcelCode":"14575-0001", "externalReference":"test parcels", "agentCode":"" }, { orderNo:"myorderno", orderLineNo:0, "orderDate":"2019-11-01", "externalParcelCode":"14575-0002", "externalReference":"test parcels", "agentCode":"" } ] }
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions