import requests
from requests.auth import HTTPBasicAuth
# Jira API details
jira_url = "xxx" # Replace with your Jira URL
email = "xxx" # Use your Jira email address
api_token = "xxx" # Use your API token
# Project details
project_key = "EX"
project_name = "Test Project"
# Jira REST API endpoint for project creation
api_url = f"{jira_url}/rest/api/2/project"
# JSON payload for creating a new project
payload = {
"key": project_key,
"name": project_name,
"projectTypeKey": "business",
"projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-simplified-process",
}
print(payload)
# Headers for the request
headers = {
"Content-Type": "application/json",
}
# Make the API call
response = requests.post(
api_url,
auth=HTTPBasicAuth(email, api_token),
json=payload,
headers=headers,
)
# Check the response status
if response.status_code == 201:
print(f"Jira project '{project_name}' created successfully!")
else:
print(f"Failed to create Jira project. Status code: {response.status_code}")
print("Response content:")
print(response.text)
I am getting the following error:
{'key': 'EX', 'name': 'Test Project', 'projectTypeKey': 'business', 'projectTemplateKey': 'com.atlassian.jira-core-project-templates:jira-core-simplified-process'}
Failed to create Jira project. Status code: 400
Response content:
{"errorMessages":["The project template specified does not exist. Make sure the project template is available in your Jira instance. Please talk to your Jira administrator if you need more help."],"errors":{"projectLead":"You must specify a valid project lead."}}