Forums

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

Create Project using REST API

Sunil Singh May 21, 2020

Hi 

I have looked at the couple of threads but not able to create project out of it.

Following is my code 

 

var _serviceUrl = Helper.Configuration.JIRAUrl + "/rest/api/3/project";
var payLoad = "{ \"key\": \"" + projectName.Substring(0, 2) + "\"," +
" \"name\": \"" + projectName + "\"," +
" \"projectTypeKey\": \"software\"," +
" \"projectTemplateKey\": \"com.pyxis.greenhopper.jira:gh-simplified-kanban\"," +
" \"description\": \"Example Project description\"," +
" \"lead\": \"admin\""+
"}";
var ItemValue = new StringContent(payLoad, Encoding.UTF8, "application/json");
var result = HttpJIRAOnline("POST", _serviceUrl, ItemValue);

 

 

Error:

{StatusCode: 400, ReasonPhrase: '', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Strict-Transport-Security: max-age=315360000; includeSubDomains; preload
ATL-TraceId: 3469dd6db518f35e
X-AREQUESTID: a3c279a0-c613-4ca9-9014-68020009f304
X-AACCOUNTID: 5d9c784b45fad00dc1261cf1
X-XSS-Protection: 1; mode=block
Transfer-Encoding: chunked
Timing-Allow-Origin: *
X-Content-Type-Options: nosniff
Micros-Issuer: micros/edge-authenticator
Connection: close
Expect-CT: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400
Cache-Control: no-store, no-transform, no-cache
Date: Fri, 22 May 2020 02:58:54 GMT
Set-Cookie: atlassian.xsrf.token=fb415e15-0205-48ba-b4f2-84da32e6dedb_7a20f41075af6f3e3deabaa2bf29b773bc0c2fcf_lin; Path=/; Secure
Server: AtlassianProxy/1.15.8.1
Content-Type: application/json; charset=UTF-8
}}

1 answer

1 accepted

0 votes
Answer accepted
DPKJ
Community Champion
May 22, 2020

@Sunil Singh  Welcome to the community.

HTTP Status Code 400 for this API implies that you are passing in some wrong values for project object.

Here is brief idea,

  • key - has to be capitalized  and less than 10 characters (please check if you are passing small case character in it)
  • projectName - seems to be correct in your case
  • projectTypeKey - 'software' is correct here
  • projectTemplateKey - you are not passing correct value here 'com.pyxis.greenhopper.jira:gh-simplified-kanban' doesn't exists, it should be 'com.pyxis.greenhopper.jira:gh-simplified-kanban-classic'

  • description - looks fine
  • lead - this is deprecated parameter use 'leadAccountId' and pass accountId of `admin` in it.

 

I hope these changes will resolve your issue.

Sunil Singh May 22, 2020

Thanks. I will try it out and update. 

Sunil Singh May 22, 2020

Thanks For the help. However,  someone really needs to update the documentation, my final Payload is this:

I had to say software instead of Software

{ "key": "DE", "name": "Debug99", "projectTypeKey": "software", "projectTemplateKey": "com.pyxis.greenhopper.jira:gh-simplified-kanban-classic", "description": "Example Project description", "leadAccountId": "5d9d96980336040dbfcbc3c6"}  

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events