Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

unable to create a project using Rest API python

Edited

I'm trying to create a project using rest api endpoint  "/rest/api/3/project",  I'm using leadAccountId key to assign a lead to the project which is throwing internal server error with "status code 405". please help me I have struck here for two days. thank you in advance



payload = json.dumps({
"notificationScheme": 10021,
"description": "Example Project description",
"lead": "<accountId>",
"url": "http://atlassian.com",
"projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-simplified-process-control",
"avatarId": 10200,
"issueSecurityScheme": 10001,
"name": "New key",
"permissionScheme": 10011,
"assigneeType": "PROJECT_LEAD",
"projectTypeKey": "business",
"key": "NK",
"categoryId": 10120
}
)

 

1 answer

1 accepted

1 vote
Answer accepted

Hello @Rajinish_Gaddam 

Welcome to the community,

 

You can use the jira library for python. Here a code to create a project :

from jira import JIRA
jira = JIRA(
basic_auth=('username"'password'), options={'server''https://jiraURL'})

jira.create_project("projectKey","projectnaame","projectlead","projecttype")

Hope this helps 

Hi @Mohamed Benziane , 

 

    thank you for immediate response, but still I'm facing the issue.

 

the above code didn't work for me. it's throwing an error 

 

 text: The referenced project template was not found - the project has not been created.

response headers = {'Server': 'AtlassianProxy/1.15.8.1', 'Vary': 'Accept', 'Cache-Control': 'no-cache, no-store, no-transform', 'Content-Type': 'application/json;charset=UTF-8', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains; preload', 'Date': 'Fri, 07 Feb 2020 12:29:01 GMT', 'ATL-TraceId': '0e4d0d7a2dec6308', 'X-AACCOUNTID': '<accountId>', 'X-AREQUESTID': '448d-ae03-cb36f12b10de', 'X-XSS-Protection': '1; mode=block', 'Transfer-Encoding': 'chunked', 'Timing-Allow-Origin': '*', 'X-Content-Type-Options': 'nosniff', 'Connection': 'close'}
response text = {"message":"The referenced project template was not found - the project has not been created.","status-code":500,"stack-trace":""}

 

can you please let me know. what information goes into lead key? in the project 

  "lead": "<accountId>",

it's throwing an internal server error while I'm creating a project 

{
    "errorMessages": [
        "Internal server error"
    ],
    "errors": {}
}

 

Can you share the code that you use with the jira library please

@Mohamed Benziane sorry for delayed response 

code:

jira.create_project(key="JP", name="jira_project", assignee="Rajinish Gadddam", type="Software")


Exception: 


jira.exceptions.JIRAError: JiraError HTTP 500 url: https://<org_url>/rest/project-templates/latest/templates
text: The referenced project template was not found - the project has not been created. 

response headers = {'Server': 'AtlassianProxy/1.15.8.1', 'Vary': 'Accept', 'Cache-Control': 'no-cache, no-store, no-transform', 'Content-Type': 'application/json;charset=UTF-8', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains; preload', 'Date': 'Sat, 08 Feb 2020 17:06:28 GMT', 'ATL-TraceId': '90c612ac36dbcd1c', 'X-AACCOUNTID': '<accountid>', 'X-AREQUESTID': '3c05740e-bb66-489d-be19-34f93ad1e0b3', 'X-XSS-Protection': '1; mode=block', 'Transfer-Encoding': 'chunked', 'Timing-Allow-Origin': '*', 'X-Content-Type-Options': 'nosniff', 'Connection': 'close'}
response text = {"message":"The referenced project template was not found - the project has not been created.","status-code":500,"stack-trace":""}

Can you try this please :

jira.create_project("JP", "jira_project", "Rajinish Gadddam","Software")

still facing the same issue @Mohamed Benziane

I'm using Jira cloud 

url = 'https://<org>.atlassian.net/rest/project-templates/latest/templates' 

error : 'The referenced project template was not found - the project has not been created.'

status_code: 500

for reference:

payload:

{
'name': 'jira_project',
'key': 'JP',
'keyEdited': 'false',
'projectTemplateWebItemKey': 'com.atlassian.jira-legacy-project-templates:jira-blank-item',
'projectTemplateModuleKey': 'com.atlassian.jira-legacy-project-templates:jira-blank-item',
'lead': 'Rajinish Gadddam',
'type': 'Software'
}

 

 

Are you sure that you have jira-software installed ?

I'm using jira cloud, is it any different form jira-software?. I'm trying to create a project using jira python module version (jira==2.0.0)

Can you use "Scrum" instead of "Software"

still same issue @Mohamed Benziane I'm not getting where I'm going wrong

 

from jira import JIRA
ORGANISATION = "https://<ord>.atlassian.net"

jira = JIRA(basic_auth=('<email>', '<api key>'), options={'server': ORGANISATION})


jira.create_project("JP", "jira_project", "Rajinish Gadddam", "Scrum")

Ok i just tried this and it's working fine :

jira.create_project(key="Python",name="Create for python",assignee="mohamed.benziane",type="Software",template_name="Scrum software development")

 here the liste of possible template:

# possible_templates =

[ # "Scrum software development",

 # "Agility",

 #"Bug tracking", 

#"JIRA Classic",

#"JIRA Default Schemes",

# "Basic software development",

# "Project management",

# "Kanban software development",

# "Task management",

# "Basic",

# "Content Management",

# "Customer service",

# "Document Approval",

# "IT Service Desk",

# "Lead Tracking",

# "Process management",

# "Procurement",

# "Recruitment", # ]

Like Rajinish_Gaddam likes this

thank you so much for your help @Mohamed Benziane  you're a life saviour.

 

another approach to the same problem:

url = "https://<org url>/rest/simplified/latest/project"
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
auth = HTTPBasicAuth("<email>", "<api key>")
project_payload = {
"name": "Jira_project",
"key": "JP",
"templateKey": "com.pyxis.greenhopper.jira:gh-simplified-kanban-classic"
}
response = requests.request(
"POST",
url,
data=json.dumps(project_payload),
headers=headers,
auth=auth
)
Like Mohamed Benziane likes this

Hi @Rajinish_Gaddam ,

I can see everytime you have been chaning url value.

How you get correct url value to create a new project?

In my case I see list of projects here at

"https://myjirasite123.atlassian.net/secure/BrowseProjects.jspa"

@Bas sorry for the delayed replay, reason I have mentioned multiple urls because I have tried all the urls mentioned by different experts until I find authentic url and @Mohamed Benziane has given an appropriate answer to create project

@Mohamed Benziane 

Hello, I wanted to ask how I can get the: projectTemplateKey of my project so that the projects that I create are created under that same template assigned to other previous projects. Thank you

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you