Exporting Project Data Using the REST Interface
Use the following information to export project data by issuing a cURL command that calls the Export Project Data REST API. During the export process, the project data is written to a JSON data file, which is then redirected to a .zip archive.
Important:When you use the Export Project Data REST API, the export does not run as a background job as it does when executed through the UI.
Note:If want to copy and paste the cURL command directly from these instructions, copy it to a text editor first to remove formatting and any line breaks or extra spaces.
To export project data by calling the exportProjectData REST API, do the following:
1. | Ensure that the requirements listed in Prerequisites for Exporting Data and Prerequisites When Using the REST Interface for Project Exports and Imports are met. |
2. | To initiate the export process, execute the following cURL command to invoke the Export Project Data REST API using the GET method. |
curl -X GET "HOSTNAME:PORT/codeinsight/api/project/exportProjectData?projectId=PROJECT_ID" -H "accept: application/json" -H "Authorization: Bearer JWT_TOKEN" > PROJECT_DATA_FILE.zip
In the command syntax, replace the highlighted variables with your server host name (machine name or IP address) along with the port, the ID of the project you are exporting, and your authorization token.
Also, replace PROJECT_DATA_FILE with the name that you want to use for the .zip archive to which the data file containing the exported data will be redirected. (The data file will use the same name, but with a .json extension.) If you provide the name of the .zip file only, the file is downloaded by default to the directory from which the export command was executed. Alternatively, you can download the file to another location by including the full path to this other location in the file name.
Note:If an archive with the same name already exists in the download location, the new archive replaces the existing one.
Example Command Calling the “Export Project Data” REST API
The following is an example cURL command calling the Export Project Data REST API:
curl -X GET "http://localhost:8888/codeinsight/api/project/exportProjectData?projectId=164" -H "accept: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInVzZXJJZCI6MSwiaWF0IjoxNTY2ODU5NTg2fQ.qV2j8ZLgNGNJsT8OdPRwvE0-0y1x7w-0zr5h7Jz2d9uqY8tvACsV68posEUO9tD-YXlgXznX-IGnrnopDU7G3w" > ProjectKDR.zip
As the command executes, the status of the export process is displayed in the command prompt window:
When the export completes, the .zip archive containing the exported data is downloaded to the directory from which the export command was executed. For instance, if the export command was executed from the C:/fnci/project_export directory and the output redirect value is ProjectKDR-export-02-20-2021_10-42.zip, the following is the archive location:
C:/fnci/project_export/ProjectKDR-export-02-20-2021_10-42.zip
Note:If the output redirect value in the example had included the full path to another location, the .zip file would have been downloaded to this other location.
The name of the data file contained in the archive is ProjectKDR-export-02-20-2021_10-42.json.