---
title: "Exporting datasets - REST v2"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/44578241/Exporting%20datasets%20-%20REST%20v2"
format: markdown
---
# Exporting datasets

Datasets can be defined for [parameterized tests](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44566351) at different levels. The respective **test issue** and optionally **context issue** must be given as **input** to the endpoint to export the dataset at a given level.

When exporting the dataset of a test in the context of a **test plan** or a **test execution**, the requested dataset can be the one actually defined at that level or the one **resolved** up to that level.


The following table shows the exported dataset for the different input combinations:

| **Test issue** | **Context issue** | **Resolved** | **Result dataset** |
| --- | --- | --- | --- |
| Yes | No | N/A | Dataset defined in the test (default dataset) |
| Yes | Test plan | `false` | Dataset defined in the test in the test plan |
| Yes | Test plan | `true` | Resolved dataset at the test plan - test level |
| Yes | Test execution | `false` | Dataset defined in the test in the test execution |
| Yes | Test execution | `true` | Resolved dataset at the test run level |


> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> |  |
> | --- |
> | Returns the a CSV file with the requested dataset for the input issue ids.<br>### <span style="color: #003366">**Request**</span>** **<br><span style="color: #003366">**QUERY PARAMETERS**</span><br>> Macro (nested-table)<br>One of `testIssueId` or `testIssueKey` is **required**. If both are provided, `testIssueId` is used.<br>Both `contextIssueId`` and ``contextIssueKey` are **optional**. If both `contextIssueId` and `contextIssueKey` are provided, `contextIssueId` is used.<br>The **resolved** flag is only relevant when requesting the dataset of a test with a **context issue**.<br>The **returned dataset** is provided with all the **iterations **generated.<br>> ✅ **Example Requests**
> > ✅ 
> > ✅ curl -X GET -H "Authorization: Bearer *$token*"  "https://xray.cloud.getxray.app/api/v2/dataset/export?testIssueKey=DEMO-1&contextIssueKey=DEMO-2&resolved=false" --output *$filename*.csv
> > ✅ 
> > ✅ 
> > ✅ *Or use the "-OJ" options to use the ****filename returned in the response****:*
> > ✅ 
> > ✅ curl -X GET -H "Authorization: Bearer *$token*" "https://xray.cloud.getxray.app/api/v2/dataset/export?testIssueKey=DEMO-1&contextIssueKey=DEMO-2&resolved=false" -OJ<br><span style="color: #003366">**Responses**</span><span style="color: #000000">** **</span><br>200 OK : **application/****octet-stream** : Successful. A CSV file will be downloaded containing the requested dataset.<br>400 BAD REQUEST : **text/plain** : No CSV file was generated. Please check the response error message.<br>401 UNAUTHORIZED : **text/plain** : The Xray license is not valid.<br>404 NO CONTENT : **text/plain** : There is no dataset for the requested level.<br>500  INTERNAL SERVER ERROR : **text/plain** : An internal error occurred when generating the CSV file. |