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

REST API create project

Administrateur Hawaii December 18, 2019

Hello, 

I've been searching on this forum and Google to find a way to create projects using Rest API. I'm not familiar with all of this and I don't find solutions really easy to understand. 

Could someone explain how to do it :) ? I've generated credentials, even the base64 Basic auth for the request. 

Thank you !  a

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 18, 2019

@Administrateur HawaiiFirst of all, welcome to the community!

Service Desk project are special kind of Jira Projects, so you can create Service Desk project using Jira's REST API by passing appropriate options, which all are explained in below API documentation link.

Please take a look at this - https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302#api-rest-api-3-project-post

0 votes
Administrateur Hawaii December 18, 2019

ok I followed instructions but when trying with curl I get 

 

curl --request POST --url 'http://mysite.net/rest/api/3/project' --user 'usermail:api key'
--header 'Accept: application/json'
--header 'Content-Type: application/json'
--data '{
"notificationScheme": 10021,
"description": "Example Project description",
"lead": "Julien",
"url": "http://mysite.atlassian.net",
"projectTemplateKey": "com.atlassian.servicedesk:simplified-internal-service-desk",
"avatarId": 10200,
"name": "TESTAPI",
"assigneeType": "PROJECT_LEAD",
"projectTypeKey": "service_desk",
"key": "TESTAPI",
"categoryId": 10120
}'

 

what should I change ? 

 

THx

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 18, 2019

@Administrateur Hawaii  Can you please elaborate on the error you are getting?

Administrateur Hawaii December 18, 2019

Oh sry I forgot half of the message... 

 

So Curl tells me that http protocol isn't supported. I mean I did exactly as in the tutorial this is going to make me crazy. 

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 18, 2019

oh! it is simple error, replace all your 'http' instance with 'https', Jira Cloud doesn't work on http, it only work on https, and hence the error.

Administrateur Hawaii December 18, 2019

It's not xD Same error https not supported or deactivated in libcurl. So I tried removing quotes from host then I get html with unauthorized error.

Then curl says : 

 

curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: notificationScheme
curl: (6) Could not resolve host: 10021,
curl: (6) Could not resolve host: description
curl: (6) Could not resolve host: Example Project description,

 

I mean why would it think this parameters are used for host, they are not..

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 18, 2019

@Administrateur Hawaii  the code below I have added to test.sh file and excuted, and it worked for me, please check.

#!/bin/bash

curl --request POST \
--url 'https://<SITE>.atlassian.net/rest/api/3/project' \
--user '<EMAIL>:<TOKEN>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"description": "My Example Project",
"projectTemplateKey": "com.atlassian.servicedesk:simplified-it-service-desk",
"name": "Example Project",
"assigneeType": "PROJECT_LEAD",
"projectTypeKey": "service_desk",
"key": "EXP",
"leadAccountId": "<MY_ACCOUNT_ID>"
}'

 

You can later run this file,

$ chmod +x text.sh
$ ./test.sh
Administrateur Hawaii December 18, 2019

"was expecting double-quote to start field name\" 

 

That's what I get :/ I'm on Windows by the way :) Maybe that's why it does that. 

 

EDIT: Ok next step I get the error "this project template does not exist..." 

 

Administrateur Hawaii December 18, 2019

curl --request POST \
--url 'https://yoursite/rest/api/3/project' \
--user 'usermail:<apikey>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"description": "My Example Project",
"projectTemplateKey": "com.atlassian.servicedesk:itil-v2-service-desk-project",
"name": "Example Project",
"assigneeType": "PROJECT_LEAD",
"projectTypeKey": "service_desk",
"key": "EXP",
"leadAccountId": "<accountid>"

}'

 

This worked perfectly :) 

 

By the way to found account id : people>select account > last alphanumeric part of url ex in bold here : /aaazer1651ezgfzeg156

Like DPKJ likes this
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 18, 2019
TAGS
AUG Leaders

Atlassian Community Events