#!/bin/bash
# RunReports -- REST curl example
# Pre-configured for the DM Web Services test environment.
# Replace YOUR_TOKEN below with your Bearer token.
# Runs a batch of reports in one call. Each entry has the same shape as a single
# RunReport request. The response carries one result entry per requested report.
# Also available over SOAP at /soap/public/v1/reports (operation RunReports).
BASE_URL="https://webservices.nebulasuite.net"
TOKEN="YOUR_TOKEN"

curl -X POST "${BASE_URL}/api/public/v1/reports/runs" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "reportRequests": [
      {
        "reportGuid": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
        "parameters": [
          { "name": "StartDate", "dataType": 4, "length": 0, "data": "2026-06-01" },
          { "name": "EndDate", "dataType": 4, "length": 0, "data": "2026-06-30" }
        ],
        "originalFileName": "JuneShipments",
        "useOriginalFileName": true,
        "correlationId": "req-2026-0629-001"
      },
      {
        "reportGuid": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
        "parameters": [
          { "name": "BranchGuid", "dataType": 12, "length": 0, "data": "1b2c3d4e-5f60-7180-92a3-b4c5d6e7f809" }
        ],
        "useOriginalFileName": false,
        "correlationId": "req-2026-0629-002"
      }
    ],
    "correlationId": "batch-2026-0629-001"
  }'
