Exporting Project Data Using the REST Interface

Code Insight 2021 R2

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: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 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.)

The following is an example:

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

The status of the export process appears in the command prompt window:

When the export completes, the .zip archive containing the exported data is found in the directory from which the export command was executed. For example, 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

The name of the data file in the archive is ProjectKDR-export-02-20-2021_10-42.json.

Note:If an archive with the same name already exists in the download location, the new archive replaces the existing one.

3. Verify that the export process completed successfully. See Verifying the Export Results.