Skip to content

Instantly share code, notes, and snippets.

@MadcapJake
Created March 30, 2016 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MadcapJake/f47f2c0f45ac4473a436b4a4f62bdb9b to your computer and use it in GitHub Desktop.
Save MadcapJake/f47f2c0f45ac4473a436b4a4f62bdb9b to your computer and use it in GitHub Desktop.
Create RT ticket in Perl 6 with Net::Curl
use v6;
use Net::Curl::NativeCall;
with curl_easy_init() {
# curl_easy_setopt($_, CURLOPT_COOKIESESSION, +True);
my Str $body;
my $login = 'user=guest&pass=guest';
curl_easy_setopt($_, CURLOPT_URL, 'https://demo.bestpractical.com/REST/1.0/');
curl_easy_setopt($_, CURLOPT_COPYPOSTFIELDS, $login);
curl_easy_setopt($_, CURLOPT_WRITEDATA, $body);
my $res = curl_easy_perform($_);
if $res != CURLE_OK {
warn sprintf("curl_easy_perform failed: %s\n", curl_easy_strerror($res))
} else {
say $body;
}
curl_easy_setopt($_, CURLOPT_URL, 'https://rt.perl.org/REST/1.0/');
my $ticket = qq:to/RT/;
id: ticket/new
Queue: General
Requestor: testsubmitter@testing.test
Subject: Testing a submitter function
Text: Here is where you would place all sorts of details about
the issue as well as anything else you feel might be important
Thanks!
RT
curl_easy_setopt($_, CURLOPT_COPYPOSTFIELDS, "$login\&content=$ticket");
curl_easy_setopt($_, CURLOPT_WRITEDATA, $body);
$res = curl_easy_perform($_);
if $res != CURLE_OK {
warn sprintf("curl_easy_perform failed: %s\n", curl_easy_strerror($res))
} else {
say $body;
}
curl_easy_cleanup($_)
} else { warn "curl failed to initialize" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment