Hi bliako,

Update

Please ignore the original version of this node. It is left there for completeness. In my haste I missed the part about adding: {'Content-type' => 'application/x-www-form-urlencoded'} to my REST call. I did and now things have moved along. Now I get all JSON results back, and the attempt to edit gives this error:
'error' => { 'code' => 'badtoken', '*' => 'See http://somehost.got.internal.net/mediawiki/api.php f +or API usage', 'info' => 'Invalid token' }
I'm sure I can work that out in a couple of minutes.

Thanks a million for you time.
R.
Original Node
thanks for taking your time on this. I see what you mean about the docco saying to put the query in the POST body and it makes sense. Something I am doing is still wrong though. I have added a print to show what the is being sent, and I have the URI and body split. Here is the post sub as is now

sub post { my $query = shift @_; print Dumper $client; $client->POST($api, $query); print "\$client->POST($api, $query)\n"; if ( $client->responseCode() == 200 ) { print "Got Data OK, decoding ... " if $debug; print Dumper $client->responseContent() ; my $data = $JSON->decode( $client->responseContent() ); print Dumper $data; return $data; } else { print "Failed with code $client->responseCode()\n"; print Dumper $client->responseContent(); } }
And here is the output, skip past the dump of the client to see that I am invoking:

$client->POST(/mediawiki/api.php, action=login&lgname=Marvin&lgpassword=diode&format=json)
random@gotsvl1140:~> ./LookupsToWiki.pl $VAR1 = bless( { '_config' => { 'host' => 'http://somehost.got.internal.net', 'useragent' => bless( { 'proxy' => {}, 'timeout' => 180, 'ssl_opts' => { 'verify_hostname' => 1 }, 'handlers' => { 'response_header' => bless( [ { 'owner' => 'LWP::UserAgent::parse_he +ad', 'callback' => sub { "DUMMY" }, 'm_media_type' => 'html', 'line' => '/usr/lib/perl5/vendor_per +l/5.18.2/LWP/UserAgent.pm:683' } ], 'HTTP::Config' ) }, 'protocols_forbidden' => undef, 'max_redirect' => 7, 'use_eval' => 1, 'max_size' => undef, 'show_progress' => undef, 'local_address' => undef, 'def_headers' => bless( { 'user-agent' => 'REST::Client/273' }, 'HTTP::Headers' ), 'no_proxy' => [], 'protocols_allowed' => undef, 'requests_redirectable' => [ 'GET', 'HEAD' ] }, 'LWP::UserAgent' ) } }, 'REST::Client' ); $client->POST(/mediawiki/api.php, action=login&lgname=Marvin&lgpasswor +d=volvo123&format=json) $VAR1 = '<!DOCTYPE html> <html lang="en" dir="ltr" class="client-nojs"> <head> <meta charset="UTF-8"/> <title>MediaWiki API help - Monitoring Services</title> <script>document.documentElement.className = document.documentElement. +className.replace( /(^|\\s)client-nojs(\\s|$)/, "$1client-js$2" );</s +cript> ","wgRelevantArticleId":0,"wgRequestId":"WwLj2gr-QFMAAE7vrZwAAAAF","wg +IsProbablyEditable":false,"wgVisualEditor":... Plenty more html here +...
there is a Sandbox here: https://www.mediawiki.org/wiki/Special:ApiSandbox Medi Wiki Sandbox but as its a web interface, I am not sure if you can hit it with Perl. I got some kids to feed now. I will log back in in a couple of hours and see if I can progress.

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

In reply to Re^4: Rest::Client Headers not getting through by Random_Walk
in thread Rest::Client Headers not getting through by Random_Walk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.