Import projects using the Web API

This section explains how to import your projects and cancel imports using the command line and Web API.

Web API access permissions are required. By default, the Project admin and Projects root admin roles have access.
In release 2024.1+, you can import projects repeatedly and import projects with identical or similar names to projects on the target server (you must specify a new name for the target server project with the newProjectName parameter).
  1. To import a given project using cURL, run the following command:
  2. curl --data "action=import_project&user=myself&project=my_project&sourceURL=
    http://oldserver:8080&sourceAdmin=user&sourcePassword=pwd" http://localhost.mycompany.com:8080/review/api

    Where:

    • project is the name of the project you want to import
    • sourceURL is the URL of the existing (source) Klocwork Server
    • sourceAdmin is the user ID of the source Klocwork Server's administrator (must have Projects root admin access)
    • sourcePassword is the administrator's password

    When you start an import, the response returns the target project ID. Save this value so that you can track or cancel the import.

    { "projectId": "<targetId>" }
  3. To cancel a queued or in-progress import, run the following command:

  4. curl --data "action=import_project_cancel&user=myself&project=<targetId>" http://localhost.mycompany.com:8080/review/api

    If the import is queued and has not started, the server removes it from the queue. If the import is in progress, it stops at the next safe checkpoint and rolls back the imported project's databases, files, and reserved project name. Imported server configuration settings are not rolled back. If the import is already complete or the project ID is unknown, the call returns an error. Sending the cancel request again while cancellation is already in progress does not change the result.

  5. To check the status of an import or cancellation, run the following command:

  6. curl --data "action=import_status&user=myself&" http://localhost.mycompany.com:8080/review/api

    While a cancellation is in progress, import_status returns cancelling as true. When the cancellation finishes, it returns cancelled as true. The cancelled state is separate from failed.

    { "<targetId>": { "stage": "...", "cancelling": false, "cancelled": true, "failed": false } }
  7. To list all projects in the source projects_root, run the following command:

  8. curl --data "action=projects&user=myself&" http://localhost.mycompany.com:8080/review/api
    
  9. To import your server configuration settings, run the following command:

  10. curl --data "action=import_server_configuration&user=myself&sourceURL=
    http://oldserver:8080&sourceAdmin=user&sourcePassword=pwd" http://localhost.mycompany.com:8080/review/api
Typically, these operations are scripted using a language, such as Python. See the Klocwork Web API cookbook for examples of scripted cURL calls that use Python.