connect to JIRA through JIRA::REST and create an issue using put/post method.

Im connecting to JIRA using JIRA::REST through perl script.And i want to create a bug/issue in jira from perl script using JIRA::REST.Can anyone help on this?

2 answers

This widget could not be displayed.

try with this script

my $pass = 'password';

#The basic use case
my $client = REST::Client->new();

#A host can be set for convienience
$client->setHost('url');

my $headers = { Authorization => 'Basic '. encode_base64($user . ':' . $pass)};

my $jsonparams =add input data here

$client->Post( '/rest/api/2/issue',$jsonparams , $headers );

if( $client->responseCode() eq '200' ){
print "Updated\n";
}

# print the result
print $client->responseContent() . "\n";


# to convert the data into a hash, use the JSON module
my $res_data = from_json( $client->responseContent() );

the input string something like this

{"fields": {
        "project": {
            "id": "10000"
        },
        "summary": "something's wrong",
        "issuetype": {
            "id": "10000"
        },
        "assignee": {
            "name": "homer"
        },
        "priority": {
            "id": "20000"
        },
        "labels": [
            "bugfix",
            "blitz_test"
        ],
        "timetracking": {
            "originalEstimate": "10",
            "remainingEstimate": "5"
        },
        "security": {
            "id": "10000"
        },
        "versions": [
            {
                "id": "10000"
            }
        ],       
        "description": "description",
        "duedate": "2011-03-11",
        "fixVersions": [
            {
                "id": "10001"
            }
        ],
        "components": [
            {
                "id": "10000"
            }
        ],
        "customfield_60000": "jira-developers",
        "customfield_20000": "06/Jul/11 3:25 PM",
        "customfield_80000": {
            "value": "red"
        },
        "customfield_40000": "this is a text field",
        "customfield_30000": [
            "10000",
            "10002"
        ],
        "customfield_70000": [
            "jira-administrators",
            "jira-users"
        ],
        "customfield_50000": "this is a text area. big text.",
        "customfield_10000": "09/Jun/81"
    }
}

This widget could not be displayed.

see for REST api here https://docs.atlassian.com/jira/REST/latest/#d2e865 for creating issue.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

292 views 5 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you