I want to create a jira project in a Perl environment.

alex seol February 11, 2019

Hi, Team.
I am a beginner in Jira and want to create a jira project using the JIRA REST API in a Perl environment.
So I saw the information (URL) below. However, there are no examples of Perlenvironment.

https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-project-get

 

So I saw JIRA :: REST and JIRA :: Client: Automated module.  But I could not get the answer I wanted.  I do not know what to do.  I am waiting for your help.

Alex.

1 answer

1 accepted

0 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2019

Hi Alex,

I was just curious if you found a solution here.  Given the related thread of https://community.atlassian.com/t5/Jira-questions/Can-I-check-the-results-of-an-issue-generated-by-the-JIRA-REST/qaq-p/1004836 is marked as solved, I hope that would help here in regards to getting this to work via Perl.

The link you cited is for getting back a list of projects.  In this case, we actually want to follow the project creation endpoint in https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-project-post

While the curl example is

curl --request POST \
  --url 'https://your-domain.atlassian.net/rest/api/3/project' \
  --header 'Authorization: Bearer ' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "key": "EX",
  "name": "Example",
  "projectTypeKey": "business",
  "projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-simplified-project-management",
  "description": "Example Project description",
  "leadAccountId": "bd429c95-e27b-4423-a0bd-421cf3d69129",
  "url": "http://atlassian.com",
  "assigneeType": "PROJECT_LEAD",
  "avatarId": 10200,
  "issueSecurityScheme": 10001,
  "permissionScheme": 10011,
  "notificationScheme": 10021,
  "categoryId": 10120
}'

We could probably translate this into a Perl syntax as well.  The tricky part I think most users get hung up here is understanding / translating all the required values here, such as "permissionScheme": 10011.   You'll actually need to know the 5 digit id number that corresponds to that permission scheme before you can create the new project.  The same goes for most of the other fields here.   Perhaps an example like this might work?

use utf8;
use Filehandle;
use strict;
use warnings;
use Encode;
use JIRA::REST;
use Data::Dumper;

my $jira = JIRA::REST -> new({
url => 'http://jira.example.com',
username => 'xxxxxx',
password => 'xxxxxx',
});

my $project = $jira -> POST('/project', undef, {
fields => {
key => 'EX', name => 'Example',
projectTypeKey => 'business', projectTemplateKey => 'com.atlassian.jira-core-project-templates:jira-core-simplified-project-management', description => 'Example Project description', leadAccountId => 'bd429c95-e27b-4423-a0bd-421cf3d69129', url => 'http://atlassian.com', assigneeType => 'PROJECT_LEAD', avatarId => 10200, issueSecurityScheme => 10001, permissionScheme => 10011, notificationScheme => 10021, categoryId => 10120
},
});

print Dumper($issue);

my $fields = $project->{fields};
my $id = $project->{id};
print "id = $id\n";

I have to admit, I'm not well versed in Perl, and I haven't tried this against a perl syntax, but given what info I have from the other thread and my knowledge on the API, I think this might work. 

I hope this helps.

Andy

alex seol February 21, 2019

Hi, Andrew

Thank you for your help.

I solved the problem through the "Atlassian Developer Community".

The cause of the problem was "wrong projectTemplateKey Value".

We sincerely appreciate the help of Atlassian's diverse community.

Cheers,

Alex

Suggest an answer

Log in or Sign up to answer