---
title: "Execută o interogare și citește rezultatul | Documentație | BI by R&D Copilot"
description: "Creează o interogare salvată, execut-o și reconciliază rândurile grupate."
canonical: "https://reports.rdcopilot.com/ro/docs/guides/run-a-question-and-read-the-result/"
language: ro
updated: 2026-11-22
---

# Execută o interogare și citește rezultatul

Creează o interogare salvată, execut-o și reconciliază rândurile grupate.

Alege metricId, perioada, compania și departamentul opționale, dimensiunea, ordinea și prezentarea. Prezentarea schimbă afișarea rândurilor, nu facturile incluse.

curl

```bash
curl -X POST "$RDC_BASE_URL/reports/v1/questions" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "41800000-0000-4000-8000-000000000127",
  "expectedRevision": 0,
  "id": "revenue-by-product",
  "metricId": "net-revenue",
  "filters": {
    "period": "2026-10",
    "companyId": null,
    "department": null
  },
  "dimension": "productLine",
  "direction": "asc",
  "presentation": "table"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/questions`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "41800000-0000-4000-8000-000000000127",
    "expectedRevision": 0,
    "id": "revenue-by-product",
    "metricId": "net-revenue",
    "filters": {
      "period": "2026-10",
      "companyId": null,
      "department": null
    },
    "dimension": "productLine",
    "direction": "asc",
    "presentation": "table"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/reports/v1/questions',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '41800000-0000-4000-8000-000000000127',
        'expectedRevision': 0,
        'id': 'revenue-by-product',
        'metricId': 'net-revenue',
        'filters': {
            'period': '2026-10',
            'companyId': None,
            'department': None,
        },
        'dimension': 'productLine',
        'direction': 'asc',
        'presentation': 'table',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "41800000-0000-4000-8000-000000000127",
  "expectedRevision": 0,
  "id": "revenue-by-product",
  "metricId": "net-revenue",
  "filters": {
    "period": "2026-10",
    "companyId": null,
    "department": null
  },
  "dimension": "productLine",
  "direction": "asc",
  "presentation": "table"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/questions');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/questions");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "41800000-0000-4000-8000-000000000127",
  "expectedRevision": 0,
  "id": "revenue-by-product",
  "metricId": "net-revenue",
  "filters": {
    "period": "2026-10",
    "companyId": null,
    "department": null
  },
  "dimension": "productLine",
  "direction": "asc",
  "presentation": "table"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Răspuns 202

```json
{
  "operationId": "41800000-0000-4000-8000-000000000127",
  "status": "accepted",
  "aggregateRevision": 1
}
```

curl

```bash
curl "$RDC_BASE_URL/reports/v1/questions/revenue-by-product" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/questions/revenue-by-product`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/reports/v1/questions/revenue-by-product',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/questions/revenue-by-product');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/questions/revenue-by-product");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Răspuns 200

```json
{
  "id": "revenue-by-product",
  "revision": 1,
  "metricId": "net-revenue",
  "filters": {
    "period": "2026-10",
    "companyId": null,
    "department": null
  },
  "dimension": "productLine",
  "direction": "asc",
  "presentation": "table"
}
```

După finalizarea creării, folosește revizia curentă și un runId nou pentru execuție. Refolosește același operationId și același corp după un timeout de rețea. Alt corp cu același operationId este refuzat.

curl

```bash
curl -X POST "$RDC_BASE_URL/reports/v1/questions/revenue-by-product/runs" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "41800000-0000-4000-8000-000000000001",
  "expectedRevision": 1,
  "runId": "41800000-0000-4000-8000-000000000002",
  "filters": {
    "period": "2026-10",
    "companyId": null,
    "department": null
  }
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/questions/revenue-by-product/runs`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "41800000-0000-4000-8000-000000000001",
    "expectedRevision": 1,
    "runId": "41800000-0000-4000-8000-000000000002",
    "filters": {
      "period": "2026-10",
      "companyId": null,
      "department": null
    }
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/reports/v1/questions/revenue-by-product/runs',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '41800000-0000-4000-8000-000000000001',
        'expectedRevision': 1,
        'runId': '41800000-0000-4000-8000-000000000002',
        'filters': {
            'period': '2026-10',
            'companyId': None,
            'department': None,
        },
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "41800000-0000-4000-8000-000000000001",
  "expectedRevision": 1,
  "runId": "41800000-0000-4000-8000-000000000002",
  "filters": {
    "period": "2026-10",
    "companyId": null,
    "department": null
  }
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/questions/revenue-by-product/runs');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/questions/revenue-by-product/runs");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "41800000-0000-4000-8000-000000000001",
  "expectedRevision": 1,
  "runId": "41800000-0000-4000-8000-000000000002",
  "filters": {
    "period": "2026-10",
    "companyId": null,
    "department": null
  }
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Răspuns 202

```json
{
  "operationId": "41800000-0000-4000-8000-000000000001",
  "status": "accepted",
  "aggregateRevision": 1
}
```

curl

```bash
curl "$RDC_BASE_URL/reports/v1/runs/41800000-0000-4000-8000-000000000002" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/runs/41800000-0000-4000-8000-000000000002`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/reports/v1/runs/41800000-0000-4000-8000-000000000002',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/runs/41800000-0000-4000-8000-000000000002');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/runs/41800000-0000-4000-8000-000000000002");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Răspuns 200

```json
{
  "id": "41800000-0000-4000-8000-000000000002",
  "revision": 1,
  "questionId": "revenue-by-product",
  "questionRevision": 1,
  "status": "completed",
  "filters": {
    "period": "2026-10",
    "companyId": null,
    "department": null
  },
  "sourceRevision": 1,
  "refreshedAt": "2026-11-22T06:00:00Z",
  "rows": [
    {
      "key": "food",
      "netRevenue": "142063.00",
      "invoiceIds": [
        "FCT-2026-00418",
        "BRR-2026-00127"
      ]
    },
    {
      "key": "household",
      "netRevenue": "60735.50",
      "invoiceIds": [
        "FCT-2026-00436"
      ]
    }
  ],
  "errorCode": null
}
```

La completed, însumează netRevenue și verifică invoiceIds pentru reconciliere. Gruparea săptămânală folosește data zilei de luni din săptămâna facturii. Fără rânduri la completed înseamnă că nu există facturi potrivite; failed este o stare distinctă, cu errorCode.
