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

jananeev October 14, 2013

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

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 14, 2013

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

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 14, 2013

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"
    }
}

Suggest an answer

Log in or Sign up to answer