Files
BC-bak/bc-export.ps1
Malin d08250a479 fix: drop $expand, fetch document lines per-document instead
The $expand approach had two fatal problems:
1. $top=50 with $expand made BC treat it as a hard limit with no
   @odata.nextLink, so only 50 docs were exported total
2. salesOrders with $expand timed out even at 50 docs when orders
   have many lines

New approach: fetch document headers normally (BC paginates fine on
its own), then for each document fetch its lines separately via
/salesInvoices({id})/salesInvoiceLines. More API calls but each is
small, fast, and reliable.

Also added:
- Invoke-BCApi with retry logic (backoff on 429/5xx/timeout)
- Separate output files: headers in {entity}.jsonl, lines in
  {lineEntity}.jsonl
- Partial data is preserved if export fails mid-way
- Progress logged every 100 documents

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 09:20:52 +01:00

13 KiB
Executable File