Importing Project Data Using the REST API

FlexNet Code Insight 2020 R1

Use the following information to export project data by using a cURL command that calls the importProjectData REST API.

Note • If copying the cURL command directly from the following instructions for your own use, copy it to a text editor first to remove formatting and any line breaks or extra spaces.

To run an import, do the following:

1. Ensure that all prerequisites in Prerequisites for Importing Data and Prerequisites When Using the REST Interface are met.
2. Set up a cURL command to invoke the importProjectData REST API using the POST method:
Create a cURL command based on the following syntax. Replace the highlighted variables with your server host ID (hostname or IP address) and port, the project ID, and the authorization token. Also, replace PROJECT_DATA_FILE with the name of .zip archive containing the JSON data file you are importing.

curl -X POST --data-binary "@PROJECT_DATA_FILE.zip" "HOST:PORT/codeinsight/api/importer/importProjectData?projectId=PROJECT_ID" -H "accept: application/json" -H "authorization: Bearer JWT_TOKEN" -H "cache-control: no-cache" -H "Content-Type: application/octet-stream"

The following is an example:

curl -X POST --data-binary "@ProjectKDRData.zip" "http://localhost:8888/codeinsight/api/importer/importProjectData?projectId=1" -H "accept: application/json" -H "authorization: Bearer eyJzdWIiOiJqcnViaW4iLCJ1c2VySWQiOjEwLCJpYXQiOjE1MTA5NjM2NzZ9" -H "cache-control: no-cache" -H "Content-Type: application/octet-stream"

Include API parameters in the command as needed to override default import behavior. See Available Import Options to Configure Import Behavior for complete details and examples.
3. Execute the command.

When the import is complete, a status message with OK will appear in the command prompt window. If the import is not successful, a status code and error message is displayed.

4. Verify that the import results are what you expected. See Verifying the Import Results.