Code Insight 2021 R2
Another option for setting up the cURL command that invokes the Import Project Data REST API (import endpoint) is to save the import attributes to a .json file and point to that file in the cURL command. For the complete instructions on running the import using this command, return to Importing Project Data Using the REST API.
To set up a cURL command that points to a file containing the import attributes, do the following:
|1.||Create and save a .json file containing the import attributes. Refer to Available Import Options to Configure Import Behavior for details about the available import attributes.|
The following shows sample file contents:
Note that the value for the inventoryFileMatchingCriteria attribute (not shown) and the reviewFileMatching attribute must be enclosed in quotes.
For purposes of example, this file is saved as Import217Settings.json, but you can provide any name with the json extension. Alternatively, you can save the json-formatted contents as a simple text file. However, when you point to the file in the cURL command, provide the file name only, not extension. For example, for Import217Settings.txt, provide only Import217Settings as the file name in the cURL command; do not include the .txt extension.
|2.||Set up the cURL command, pointing to the file containing the import attributes.|
The following shows the cURL command syntax:
curl -H "Authorization:Bearer JWT_TOKEN" -F importFile=@"FILE_TO_IMPORT.zip" -F projectImportModel=@"IMPORT_SETTINGS.json;type=application/json" http://HOSTNAME:PORT/codeinsight/api/projects/PROJECT_ID/import
This is an example of the cURL command:
curl -H "Authorization:Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInVzZXJJZCI6MSwiaWF0IjoxNTY2ODU5NTg2fQ.qV2j8ZLgNGNJsT8OdPRwvE0-0y1x7w-0zr5h7Jz2d9uqY8tvACsV68posEUO9tD-YXlgXznX-IGnrnopDU7G3w" -F importFile=@"1184-export-02-20-2021_09-40.zip" -F projectImportModel=@"Import217Settings.json;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.|
|•||ImportSettings has been replaced with the name of the example file containing the import attributes. In this case, the file is Import217Settings.json. The entire file name and type 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.|