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.
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.
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:
- Ensure that the requirements listed in Prerequisites for Exporting Data and Prerequisites When Using the REST Interface for Project Exports and Imports are met.
- To initiate the export process, execute the following cURL command to invoke the
Export Project DataREST API using the GET method.- curl -X GET "
HOSTNAME:PORT/codeinsight/api/project/exportProjectData?projectId=PROJECT_ID" -H "accept: application/json" -H "Authorization: BearerJWT_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_FILEwith the name that you want to use for the.ziparchive to which the data file containing the exported data will be redirected. (The data file will use the same name, but with a.jsonextension.) If you provide the name of the.zipfile 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. -
If an archive with the same name already exists in the download location, the new archive replaces the existing one.
- curl -X GET "
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
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.
[Removed until clarified] Troubleshooting a Failed Export
If a project data export fails, you can use this procedure as one method to troubleshoot cause of the failure.
To troubleshoot a failed export, do the following:
- Extract the
.zipfile resulting from the export.- The
.ziparchive includes the JSON data file (with the same name as the archive), which contains any data exported from the project. The archive also includes a file whose contents identify the status code and associated error message related to the failed process.
- The
- Open the JSON file with a utility that supports JSON, such as Textpad or Notepad++.
- Review the contents of the JSON file to determine any noticeable errors, especially within the context of the status code and associated error message.
- If errors exist, resolve them if possible (for example, modify the project whose data you exported and rescan the project).
- If you resolved any errors, delete the invalid archive file, and rerun the export.
[Add a final step for UI and API procedures to verify that the export process has completed successfully and to see this section.]