NAME

Confluence::Client::XMLRPC - Client for the Atlassian Confluence wiki, based on RPC::XML

VERSION

version 2.3

SYNOPSIS

my $object = Confluence::Client::XMLRPC->new( <URL>, <user>, <pass> );
my $result = $object->method(argument,..);

# Starting with version 2.3 of this module you can pass a fourth value to
# new, denoting the Confluence API version to use (see below).

my $object = Confluence::Client::XMLRPC->new( <URL>, <user>, <pass>, 2 );

CAVEAT

ATTENTION, please: This module was written by Asgeir Nilsen in 2004 and later on improved by Giles Lewis, Martin Ellis, and Torben K. Jensen.

I - Heiko Jansen - only took the available source code and created a CPAN distribution for it, because at least to me a Perl module almost does not exist if it's not on available via CPAN.

This package should work with any remote API function.

The original authors tested it with addUserToGroup, getActiveUsers, getPage, getPages, getServerInfo, getUser, and storePage. I (Heiko Jansen) have used it successfully to create and update pages, but I did not test most other API functions and am thus unable to give any guarantee that it will work as expected!

The original module was simply named "Confluence" but since Atlassian is currently working on a new REST-based API and since there already is Jira::Client and Jira::Client::REST on CPAN I renamed it to Confluence::Client::XMLRPC.

ERROR HANDLING

This package has two global flags which control error handings.

Confluence::Client::XMLRPC::setRaiseError(1);  # Enable die
Confluence::Client::XMLRPC::setPrintError(1);  # Enable warn
Confluence::Client::XMLRPC::setRaiseError(0);  # Disable die
Confluence::Client::XMLRPC::setPrintError(0);  # Disable warn

The setRaiseError and setPrintError functions both return the previous setting of the flag so that it may be restored if necessary.

RaiseError is initially set to 1 to preserve the original package behavior.

PrintError is initially set to 0.

If RaiseError is set to 0 then Confluence::Client::XMLRPC::lastError() can be used to determine if an error occurred.

Confluence::Client::XMLRPC::setRaiseError(0);
my $page = $wiki->getPage($space, $title);
if ( my $e = Confluence::Client::XMLRPC::lastError() ) {
    say $e;
}

API VERSION

Analogous to the global error handling flags there is a flag to set the API version to use:

Confluence::Client::XMLRPC::setApiVersion($num); # set the version

The setApiVersion function returns the previous setting of the flag so that it may be restored if necessary. The function accepts both plain numbers ("1" or "2") or the full version namespaces ("confluence1", "confluence2").

The version 2 of the API was introduced with Confluence 4.0 and Atlassian recommends to use the newer version.

However, due to backwards compatibility reasons the default value for the API version in this module still is 1. Note: you can use most but not all of the version 1 API calls on newer Confluence installations!

For a detailed and authoritative description of the differences between versions 1 and 2 of the API please refer to https://developer.atlassian.com/display/CONFDEV/Confluence+XML-RPC+and+SOAP+APIs#ConfluenceXML-RPCandSOAPAPIs-v2apiRemoteAPIversion1andversion2!

USAGE

Data types

Perl simple data types are mapped to string. Hash references are mapped to struct. Array references are mapped to array.

This package now automatically converts all scalars to RPC::XML::string, so explicit type conversions should not be required.

API extension

updatePage

This package has a function called updatePage which is not part of the original remote API. If the page id is not specified then the function will call storePage to do an insert. If an "already exists" error is encountered then the function will call getPage to retrieve the page id and version, and then repeat the storePage attempt. This function is intended to be used in situations where the intent is to upload pages, overwriting existing content if it exists. See example below.

EXAMPLES

upload_files.pl - Upload files

The sample script uploads the contents of a directory to the wiki. Each file in the directory is uploaded as a separate page. The page title is the file name with extension removed. This script requires five arguments: API url, user name, password, space key and a directory name.

upload_users.pl - Upload Users

This script reads and loads a list of users from a file (or stdin). If errors are encountered then the script will print an error message, but continue processing. This script requires three arguments: API url, name and password of an admin user.

det_group_mbrship.pl - Determine Group Membership

The script prints the group membership of all users. This script requires three arguments: API url, name and password of an admin user.

Please refer to the examples directory of the distribution for the scripts themselves.

SEE ALSO

The package uses the RPC::XML module to do the heavy lifting. Read the perldoc for this package to learn more.

For further information on the Confluence API itself please refer to the official documentation as provided by Atlassian.

AUTHORS

  • Asgeir Nilsen

  • Giles Lewis

  • Martin Ellis

  • Torben K. Jensen

  • Heiko Jansen <hjansen@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2014 by Heiko Jansen.

This is free software, licensed under:

The GNU General Public License, Version 2, June 1991