Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Get Token and use it in Perl confluence.pm rpc-xml method calls

Craig Solinski October 31, 2011

Hi,

Using Perl, I'm successful calling Confluence.pm rpc-xml commands that don't need 'token' passed it but not with any that require it. Confluence version 3.5.13.

Does anyone know how to get confluence token in format that is valid to pass to confluence API?

Seems certain command on https://developer.atlassian.com/display/CONFDEV/Confluence+XML-RPC+and+SOAP+APIs

require an authentication token be passed while for others its actually optional.

Start Perl script by getting a handle to Confluence successfully like:

my $wiki = new Confluence($url, $user, $password); # works fine and so do some other calls to API methods.

# Get Token which according to API is suppossed to return a string:

my $token = $wiki->login($url, $user, $password); # found $URL was required even though API does not show it.

print of token looks like: 'Confluence=HASH(0x1008050b2)' - Which suprisingly matches the printed value of $wiki

# Then use it like:

$bool = $wiki->removeGroup($token, $group);

# Execution Fails and complains about signiture - seems token is interpreted as a string and Hash. Error msg:

REMOTE ERROR: java.lang.NoSuchMethodException: $Proxy737.removeGroup(java.lang.String, java.util.Hashtable, java.lang.String)

Does anyone know how to get confluence token in format that is valid to pass to confluence API?

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 31, 2011

> print of token looks like: 'Confluence=HASH(0x1008050b2)'

That's a reference to a hash (ie a map, a dictionary etc).

Try adding at the top:

use Data::Dumper;

then

print Dumper $token

The token is a scalar, so you need to get it out of the hash. Not sure why you're getting a hash but if you post the output from Dumper it should be clear.



0 votes
Leo B November 2, 2011

Do it like this:

my $confluence = SOAP::Lite->proxy('http://<confluence-page>/rpc/soap-axis/confluenceservice-v1?wsdl');

my $token = $confluence->login($adminuser, $adminpass);

Then, when you need to use the Token on the methods, write this: $token->result()

Cheers...

Craig Solinski November 16, 2011

Thanks to both of you, I've been temporarily diverted to another priority and plan to respond to both your replies in the not too distant future.

Thanks,

Craig

Craig Solinski December 19, 2011

Hello and thank you both for your insight. I've been able to connect and get token and use some of the confluence API using Perl with XMLRPC, XMLRPC calling CLI, and SOAP::LITE.

Does anyone have any Perl/SOAP::LITE examples that work with Confluence API - specifically I'm needing a bit more insight in how to get at the individual fields/values out of what is returned when using for example 'getComment', or 'getComments'.

Thank you and happy Holidays,
Craig

0 votes
Leo B November 2, 2011

Do it like this:

my $confluence = SOAP::Lite->proxy('http://<confluence-page>/rpc/soap-axis/confluenceservice-v1?wsdl');

my $token = $confluence->login($adminuser, $adminpass);

Then, when you need to use the Token on the methods, write this: $token->result()

Cheers...

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events