Explicitly Provide the Import Attributes in the cURL Command

Code Insight 2021 R2

One option for setting up the cURL command that invokes the Import Project Data REST API (import endpoint) is to explicitly include the import attributes in the command. For the complete instructions on running the import using this command, return to Importing Project Data Using the REST API.

The following shows the cURL command syntax with the available import attributes:

curl -H "Authorization:Bearer JWT_TOKEN" -F importFile=@"FILE_TO_IMPORT.zip" -F projectImportModel={ \"createEmptyInventory\” : true/false, \“overwriteInventoryNotes\” : true/false, \“addFilesToInventory\” : true/false, \“inventoryFileMatchingCriteria\” : \“FileMatchingCriteria\”, \“inventoryDirectoryDepth\” : 1-20, \“markFilesAsReviewed\” : true/false, \“reviewFileMatchingCriteria\” : \“FileMatchingCriteria\”, \“reviewDirectoryDepth\” : 1-20 };type=application/json http://HOSTNAME:PORT/codeinsight/api/projects/PROJECT_ID/import

This next code excerpt is an example of the cURL command. Refer to Available Import Options to Configure Import Behavior for details about the available import attributes.

curl -H "Authorization:Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInVzZXJJZCI6MSwiaWF0IjoxNTY2ODU5NTg2fQ.qV2j8ZLgNGNJsT8OdPRwvE0-0y1x7w-0zr5h7Jz2d9uqY8tvACsV68posEUO9tD-YXlgXznX-IGnrnopDU7G3w" -F importFile=@"1184-export-4-02-20-2021-40.zip" -F projectImportModel={ "createEmptyInventory” : true, “overwriteInventoryNotes” : false, “addFilesToInventory” : true, “inventoryFileMatchingCriteria” : “MD5_AND_PARTIAL_FILEPATH”, “inventoryDirectoryDepth” : 2, “markFilesAsReviewed” : true, “reviewFileMatchingCriteria” : “PARTIAL_FILEPATH”, “reviewDirectoryDepth” : 2 };type=application/json http://localhost:8888/codeinsight/api/projects/217/import

Note the following about the example command. Users must explicitly provide their own values in the command based on their environment.

JWT_TOKEN has been replaced with an example user authorization token.
HOSTNAME:PORT has been replaced with an example machine name and port—in this case, localhost:8888. (The IP address for the machine can be used instead of the machine name.)
FILE_TO_IMPORT has been replaced with the name of an import data file (that is, the file name of the zip file to be imported) in the example. In this case, the import data file is 1184-export-02-20-2021_09-40.zip. The entire file name must be enclosed in quotes.
PROJECT_ID has been replaced with the ID of the project to which data is being imported (in this case, 217). See Project ID for help on obtaining the project ID.
The value for the inventoryFileMatchingCriteria and reviewFileMatching attributes must be enclosed in quotes.