Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira REST API 'Create a Project' returning status 200

Peter Jupp
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 18, 2020

I am trying to write a quick script that creates a Jira project using the REST API. This code, taken from the docs (https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/#api-rest-api-3-project-post) is returning status 200 - instead of 201, and no new project is being created.

 

I'm pretty confident that I have set up everything correctly jira-side w.r.t. global permissions, etc. (my account is an admin with full access).

 

Any ideas why this might be happening?

 

 

The Code (Python)

Note: Text in bold has been replaced for confidentiality reasons.


import requests
from requests.auth import HTTPBasicAuth
import json

url = "http://domain.atlassian.net/rest/api/3/project"

auth = HTTPBasicAuth("email", "api key")

headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}

payload = json.dumps( {
"notificationScheme": 10021,
"description": "Example Project description",
"leadAccountId": "my account ID",
"url": "http://atlassian.com",
"projectTemplateKey": "com.pyxis.greenhopper.jira:gh-simplified-scrum-classic",
"avatarId": 10200,
"issueSecurityScheme": 10001,
"name": "Example",
"permissionScheme": 10011,
"assigneeType": "PROJECT_LEAD",
"projectTypeKey": "software",
"key": "EXIT",
} )

response = requests.request(
"POST",
url,
data=payload,
headers=headers,
auth=auth
)

print(response) #returns <Response[200]>
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

1 answer

0 votes
Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 19, 2020

Hello @Peter Jupp

Welcome to the Atlassian Community!

The structure of your REST API call seems to be correct to me, however, there are a few background data that I would like to doublecheck with you to confirm we are on the same page here.

That being said, please check the steps below:

  1. I see you added most of the parameter values (issueSecurityScheme, permissionScheme, etc) with the same values listed in the REST API example. Can you confirm if those values are indeed related to the parameters you have in your existing Jira site? Please, note that those values are just examples and your site might have different values for those parameters. Refer to this documentation to see how you can get the values of each parameter on the REST API body.
  2. Even though you are a site admin, please confirm if you have the proper permissions to Browse projects in the Permission scheme added (10011) and if your user is added to the security scheme selected (10001).
  3. Ensure you have followed the steps of the documentation below to generate your API token and that it's still valid for your user:
    Jira API Tokens 
  4. If possible, try to run the same query using a different method (Curl, Java, etc) and check if it works for you.

Let us know if you have any other questions.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events