$ErrorActionPreference = "Stop" $baseUrl = ($env:PUBLIC_API_BASE_URL ?? "https://api.compudime.com").TrimEnd("/") $apiKey = $env:PUBLIC_API_KEY if ([string]::IsNullOrWhiteSpace($apiKey)) { throw "Set PUBLIC_API_KEY to before running this example." } $headers = @{ Authorization = "Bearer $apiKey" "X-Request-Id" = "catalog-sync-$([guid]::NewGuid().ToString("N"))" } $fields = [uri]::EscapeDataString("productCode,description,price") $page = Invoke-RestMethod -Method Get -Headers $headers -Uri "$baseUrl/v1/products?fields=$fields&limit=50" $page.products | Select-Object productCode, description, price if ($page.nextCursor) { $cursor = [uri]::EscapeDataString($page.nextCursor) $next = Invoke-RestMethod -Method Get -Headers $headers -Uri "$baseUrl/v1/products?fields=$fields&limit=50&cursor=$cursor" "Fetched $($next.products.Count) products from the next page." }