Skip to content

Instantly share code, notes, and snippets.

@nicolasrouanne
Created October 7, 2016 08:18
Show Gist options
  • Save nicolasrouanne/cdb1a3a269226c74549ba70adf813e42 to your computer and use it in GitHub Desktop.
Save nicolasrouanne/cdb1a3a269226c74549ba70adf813e42 to your computer and use it in GitHub Desktop.
Perl script to parse Targetprocess User Stories (and other objects) and print them out
#!/usr/local/bin/perl
use strict;
use warnings;
use MIME::Base64;
use REST::Client;
use utf8;
use Encode qw( encode_utf8 );
use JSON qw( decode_json );
# `@` characters need to be escaped with \ in api_key and pass
my $api_key = "username";
my $api_pass = "password"; # `@` characters need to be escaped with \
my $client = REST::Client->new();
$client->setHost("https://nomadeducation.tpondemand.com");
$client->addHeader("Authorization", "Basic " .
encode_base64("$api_key:$api_pass", ""));
my $response = $client->GET("/api/v1/Bugs/?include=%5BName,Description%5D&where=EntityState.Name%20eq%20'In Testing'&format=json&take=10000&acid=C3502BD198B4964B09E9B21ABD0B7849");
# Uncomment following line to see the GET response
#print $client->responseCode();
#print $client->responseContent();
# Parse JSON and make sure it is treated as UTF-8
my $json = $client->responseContent();
my $decoded = decode_json(encode_utf8($json));
# Print the Name or Description of the ressource in Target Process
my @ressources = @{ $decoded->{'Items'} };
foreach my $r ( @ressources ) {
print $r->{"Name"} . "\n";
#print $r->{"Description"} . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment