Creating a Snapshot for a Single Jira Project Using the REST API

This article explains creating a snapshot for project with issues using the Configuration Manager for Jira (CMJ) REST API.

Prerequisites:

  • Ensure that you have administrative access to the Jira instance.

  • Verify that you are using CMJ version 6.14.0 or later, as this includes the necessary API version (1.6).

Step-by-Step Guide

1. Setting Up the API Call

To create a snapshot for a specific Jira project, you must define the projectKey in your API request. Below is the basic structure for making a POST request to the CMJ REST API:

curl -u "<LOGIN>:<PASSWORD>" -i -H "Content-Type: application/json" \\ -X POST "<JIRA_URL>/rest/configuration-manager/api/1.6/snapshots" \\ -d '{ "name" : "Your Snapshot Name", "description" : "Description of the snapshot", "scope" : "projectWithIssues", "projectKey" : "YOUR_PROJECT_KEY" }'

Replace the placeholders (<LOGIN>, <PASSWORD>, <JIRA_URL>, and YOUR_PROJECT_KEY) with your actual Jira credentials, instance URL, and the project key you wish to snapshot.

2. Common Errors and Troubleshooting

  • Authentication Error: If you encounter an error message such as Basic Authentication Failure - Reason: AUTHENTICATION_FAILED, ensure that you are using correct login credentials and not a Jira API token. Basic authentication requires your Jira username and password.

  • Scope Issues: Ensure that the scope parameter is correctly set to "projectWithIssues". This scope limits the snapshot to the specific project defined by projectKey.

  • API Versioning: Make sure your API endpoint is using version 1.6. This is compatible with CMJ version 6.14.0 and later. You can check your installed plugin version by navigating to the Manage Apps section in Jira.

3. Example Command

Below is an example of a successful API call:

curl -u "admin:admin_password" -i -H "Content-Type: application/json" \\ -X POST "<http://your-jira-instance.com/rest/configuration-manager/api/1.6/snapshots>" \\ -d '{ "name" : "My Project Snapshot", "description" : "Snapshot for project PRJ", "scope" : "projectWithIssues", "projectKey" : "PRJ" }'

Upon successful execution, you should receive a 201 Created response with a Location header pointing to the newly created snapshot.

FYI: REST API Automation REST API: Configuration Manager