Importing Project Data Using the REST API

FlexNet Code Insight 2019 R3

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. To initiate the import process, execute the following cURL command to invoke the importProjectData REST API using the POST method. 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 "@MyProjectDataFile.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"

Note • Inventory items without file associations are never imported by default. If you are importing from a scanned project into an inventory-only project, you must add the createEmptyInventory=true option for inventory to be generated in the new project. See Available Import Options to Control Import Behavior for details.

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.

3. To verify that the import has completed successfully, follow these steps:
a. Open the target project in FlexNet Code Insight and navigate to the Inventory page (see Searching the System).
b. Confirm that the total number of inventory items includes the newly imported items. (Keep in mind that, by default, only inventory with matching associated files in the target codebase are imported.)
c. Confirm that the inventory items contain accurate inventory details and file path associations.