Skip to main content

Perl

GET

use warnings;
use IO::Socket::SSL;
use HTTP::Request ();
use LWP::UserAgent ();
use JSON::MaybeXS qw(encode_json);

my $url = '<YOUR ENDPOINT URL>';
my $header = [
'Content-Type' => 'application/json; charset=UTF-8',
'Accept' => 'application/json',
'apiKey'=>'<YOURTOKEN>'];
my $data = {
options => {
method => 'GET',
headers => { 'Content-Type'=> 'application/json', Accept => 'application/json'}},
url => '/rest/api/3/issue/DEV-16'
};
my $encoded_data = encode_json($data);

my $request = HTTP::Request->new('POST', $url, $header, $encoded_data);
my $ua = LWP::UserAgent->new;
my $response = $ua->request($request);
my $res = $response->content;
print "r : ${res}";

POST

use warnings;
use IO::Socket::SSL;
use HTTP::Request ();
use LWP::UserAgent ();
use JSON::MaybeXS qw(encode_json);

my $url = '<YOUR ENDPOINT URL>';
my $header = [
'Content-Type' => 'application/json; charset=UTF-8',
'Accept' => 'application/json',
'apiKey'=>'<YOURTOKEN>'];
my $data = {
options=> {
method=> "POST",
headers=> {
'Content-Type'=>"application/json",
Accept=>"application/json"
},
body=> {
fields=> {
project=>{
name=> "<your project name>"
},
summary=> "Create Issue via POST.",
description=>"Creating of an issue via a POST request using the API Key Manager",
issuetype=> {
id=>"<your issue type id>"
}
}
}
},
url=>"/rest/api/2/issue"
};

my $encoded_data = encode_json($data);

my $request = HTTP::Request->new('POST', $url, $header, $encoded_data);
my $ua = LWP::UserAgent->new;
my $response = $ua->request($request);
my $res = $response->content;
print "r : ${res}";