My company recently bought the Confluence software from Atlassian. Confluence is a web based collaboration system, allowing users to upload
documents and other content to their personal pages, and to provide for project teams to collaborate together and share documentation. The software
also tracks changes to the documentation as well.
I have been tasked with automating some tasks that occur on a daily basis, mostly updating verification reports of our various databases, and then
publishing those to Confluence.
Confluence has several APIs, and the easiest for me to use was the RPC-XML client, as I could do it with perl. A search of CPAN gave
me the
Confluence::Client::XMLRPC module. So I created the following short script, to make sure I could do what I want:
#!C:\Perl64\bin\perl
use strict;
use warnings;
use Confluence::Client::XMLRPC;
my $version=2;
Confluence::Client::XMLRPC::setApiVersion($version);
Confluence::Client::XMLRPC::setRaiseError(1);
Confluence::Client::XMLRPC::setPrintError(1);
my $URL="https://jeeves.Mainoffice.Demoulas.Corp/rpc/xmlrpc/";
my $user="toms";
my $pass="password";
my $object = Confluence::Client::XMLRPC->new($URL,$user,$pass);
$object->logout();
which produced the following error:
XML-RPC ERROR: Unable to connect to https://jeeves.Mainoffice.Demoulas
+.Corp/rpc/xmlrpc
at C:\Users\toms\Documents\Confluence\confluence.pl line 15
After a great deal of trial and error, I got the code below working:
#!C:\Perl64\bin\perl
use warnings;
use strict;
use LWP::UserAgent;
my $ua=LWP::UserAgent->new(ssl_opts=>{ verify_hostname => 0});
my $req = HTTP::Request->new(GET => 'https://jeeves.mainoffice.demoula
+s.corp');
my $result = $ua->request($req);
if($result->is_success){
print $result->content;
}else{
print $result->status_line, "\n";
}
The catch is where I create the LWP object, telling the agent to not verify the hostname of the server. If I remove the ssl_opts, it
will say it can not connect due to failing the certificate verification.
The Confluence client in the first bit of code uses LWP and LWP::Protocol::https to handle the http/https part of connecting to
the server. What I need to figure out is how I can pass the ssl_opts.
I am currently testing all of this on Windows 7 (64 bit), running ActiveState Perl 5.18.2
TStanley
--------
People sleep peaceably in their beds at night only because rough men stand ready to do violence on their behalf. -- George Orwell
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.