Samuel Lampa | 1 Apr 2009 12:13

Error on action=query (trying to get edit token)

I'm following the following help page, in order to receive an edit token 
(I'm using MW 1.14.0):
http://www.mediawiki.org/wiki/API:Edit_-_Create%26Edit_pages

It tells to use the Url on the following form:
api.php?action=query&prop=info|revisions&intoken=edit&titles=Main%20Page

But that gives me the following error:

<?xml version="1.0"?>
<api>
  <error code="unknown_action" info="Unrecognized value for parameter &#039;action&#039;: query">

I've tried to execute the query with both GET (directly in the browser) 
and POST (via Curl in PHP) with the same result. Have also tried the 
following combinations with the same result:
api.php?action=query&prop=info|revisions and
api.php?action=query

Am I doing anything wrong, or is this the correct way to get an edit token?

Regards
Samuel Lampa
http://www.rilnet.com
Samuel Lampa | 1 Apr 2009 14:54

[solved] Re: Error on action=query (trying to get edit token)

Well, it all was due to a user rights setting in LocalSettings.php:
$wgGroupPermissions['*'    ]['read']            = false;

Since I want to keep this setting, is it possible to enable access to 
the API only though settings in LocalSettings.php?
The following did not help:
$wgGroupPermissions['*']['writeapi'] = true;

// Samuel

Samuel Lampa skrev:
> I'm following the following help page, in order to receive an edit token 
> (I'm using MW 1.14.0):
> http://www.mediawiki.org/wiki/API:Edit_-_Create%26Edit_pages
>
> It tells to use the Url on the following form:
> api.php?action=query&prop=info|revisions&intoken=edit&titles=Main%20Page
>
> But that gives me the following error:
>
> <?xml version="1.0"?>
> <api>
>   <error code="unknown_action" info="Unrecognized value for parameter &#039;action&#039;: query">
>
> I've tried to execute the query with both GET (directly in the browser) 
> and POST (via Curl in PHP) with the same result. Have also tried the 
> following combinations with the same result:
> api.php?action=query&prop=info|revisions and
> api.php?action=query
>
(Continue reading)

Samuel Lampa | 1 Apr 2009 16:16

Re: [solved] Re: Error on action=query (trying to get edit token)

Samuel Lampa skrev:
> Since I want to keep this setting, is it possible to enable access to 
> the API only though settings in LocalSettings.php?
> The following did not help:
> $wgGroupPermissions['*']['writeapi'] = true;

Well, this is not really needed anymore either, since I now managed to 
log in through the API.

First I had problems doing that. My major obstacle was how to store the 
cookie when connecting through cURL/PHP, but that was solved by using 
the cURL class posted at 
http://www.php.net/manual/en/book.curl.php#86391 , which takes care of 
cookies et.c.

// Samuel
Roan Kattouw | 1 Apr 2009 23:45
Picon

Re: [solved] Re: Error on action=query (trying to get edit token)

2009/4/1 Samuel Lampa <samuel.lampa.l <at> rilnet.com>:
> Samuel Lampa skrev:
>> Since I want to keep this setting, is it possible to enable access to
>> the API only though settings in LocalSettings.php?
>> The following did not help:
>> $wgGroupPermissions['*']['writeapi'] = true;
>
> Well, this is not really needed anymore either, since I now managed to
> log in through the API.
>
You're correctly pointing out that acting like action=query doesn't
exist to users who don't have permission to use it is confusing and
wrong. This has been fixed on trunk, which means it shouldn't be
happening on Wikipedia anymore and won't happen in MW 1.15+.

Roan Kattouw (Catrope)
Samuel Lampa | 1 Apr 2009 23:58

Re: [solved] Re: Error on action=query (trying to get edit token)

Roan Kattouw skrev:
> 2009/4/1 Samuel Lampa <samuel.lampa.l <at> rilnet.com>:
>   
>> Samuel Lampa skrev:
>>     
>>> Since I want to keep this setting, is it possible to enable access to
>>> the API only though settings in LocalSettings.php?
>>> The following did not help:
>>> $wgGroupPermissions['*']['writeapi'] = true;
>>>       
>> Well, this is not really needed anymore either, since I now managed to
>> log in through the API.
>>
>>     
> You're correctly pointing out that acting like action=query doesn't
> exist to users who don't have permission to use it is confusing and
> wrong. This has been fixed on trunk, which means it shouldn't be
> happening on Wikipedia anymore and won't happen in MW 1.15+.
>   
Ok, thanks for the information!

// Samuel
Samuel Lampa | 17 Apr 2009 16:57

Can't post data bigger than 5420 bytes

I'm having some troubles can't post article content via API that is 
bigger than ~5420 bytes. 5420 bytes works, but 5454 bytes fails.
And the problem is that I don't get any result or error message back.

Anyone had similar problems?
Is there some general size limit for posting through the API, that I'm 
exceeding? (Strange though that I don't get an error message)

More detailed info:
I'm using PHP Version 5.2.4-2ubuntu5.5 with cURL
Post max size in php.ini is 16M

I'm using the cURL handle class below (The functions "cURLHandle" 
(constructor) and "post" should be the ones relevant here). As you can 
see the timeout is set to 30 seconds ("curl_setopt($process, 
CURLOPT_TIMEOUT, 30);" in the post function), but it doesn't take more 
than merely a second or so before the execution ends.

class cURLHandle {
  var $headers;
  var $user_agent;
  var $compression;
  var $cookie_file;
  var $proxy;
  function 
cURLHandle($cookies=TRUE,$cookie='./cookies/cookies.txt',$compression='gzip',$proxy='') 
{
    $this->headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, 
image/pjpeg';
    $this->headers[] = 'Connection: Keep-Alive';
(Continue reading)

Samuel Lampa | 17 Apr 2009 17:06

Re: Can't post data bigger than 5420 bytes

Oh, and I'm using MediaWIki 1.14.0 (r194) and Apache 2.

// Samuel

Samuel Lampa skrev:
> I'm having some troubles can't post article content via API that is 
> bigger than ~5420 bytes. 5420 bytes works, but 5454 bytes fails.
> And the problem is that I don't get any result or error message back.
>
> Anyone had similar problems?
> Is there some general size limit for posting through the API, that I'm 
> exceeding? (Strange though that I don't get an error message)
>
> More detailed info:
> I'm using PHP Version 5.2.4-2ubuntu5.5 with cURL
> Post max size in php.ini is 16M
>
> I'm using the cURL handle class below (The functions "cURLHandle" 
> (constructor) and "post" should be the ones relevant here). As you can 
> see the timeout is set to 30 seconds ("curl_setopt($process, 
> CURLOPT_TIMEOUT, 30);" in the post function), but it doesn't take more 
> than merely a second or so before the execution ends.
>
> class cURLHandle {
>   var $headers;
>   var $user_agent;
>   var $compression;
>   var $cookie_file;
>   var $proxy;
>   function 
(Continue reading)

Sam Korn | 17 Apr 2009 17:07
Picon

Re: Can't post data bigger than 5420 bytes

On Fri, Apr 17, 2009 at 3:57 PM, Samuel Lampa <samuel.lampa.l <at> rilnet.com> wrote:
> I'm having some troubles can't post article content via API that is
> bigger than ~5420 bytes. 5420 bytes works, but 5454 bytes fails.
> And the problem is that I don't get any result or error message back.
>
> Anyone had similar problems?
> Is there some general size limit for posting through the API, that I'm
> exceeding? (Strange though that I don't get an error message)

This might be due to the Squid changes detailed at
https://secure.wikimedia.org/wikipedia/en/wiki/Wikipedia:Bot_owners%27_noticeboard/Archive_4#Squid_Changes

You are probably receiving a 417 HTTP header in return.

Try adding "Expect:" to your array of HTTP headers, so the following
needs to go in cURLHandle():

$this->headers[] = 'Expect:';

Sam

--

-- 
Sam
PGP public key: http://en.wikipedia.org/wiki/User:Sam_Korn/public_key
Samuel Lampa | 17 Apr 2009 17:31

Re: [Resoved] Can't post data bigger than 5420 bytes

Thanks for your quick response. I forgot to say though that I'm not 
actually connecting against Wikipedia servers, but my own server.

I found the problem as well: I'm using the Tooltip extension, and it 
turns out that adding too many tooltips is what made the server stop 
responding, not the article size per se. Probably the parsing of the 
tooltips are somewhat resource intensize. Posting without any tooltip 
code works fine with far greater article sizes.

Regards
// Samuel

Sam Korn skrev:
> On Fri, Apr 17, 2009 at 3:57 PM, Samuel Lampa <samuel.lampa.l <at> rilnet.com> wrote:
>   
>> I'm having some troubles can't post article content via API that is
>> bigger than ~5420 bytes. 5420 bytes works, but 5454 bytes fails.
>> And the problem is that I don't get any result or error message back.
>>
>> Anyone had similar problems?
>> Is there some general size limit for posting through the API, that I'm
>> exceeding? (Strange though that I don't get an error message)
>>     
>
> This might be due to the Squid changes detailed at
> https://secure.wikimedia.org/wikipedia/en/wiki/Wikipedia:Bot_owners%27_noticeboard/Archive_4#Squid_Changes
>
> You are probably receiving a 417 HTTP header in return.
>
> Try adding "Expect:" to your array of HTTP headers, so the following
(Continue reading)

Beebe, Mary J | 27 Apr 2009 15:56
Picon
Favicon

Query lgtoken error.

I am using Java to work with the mediawiki Api.  We would like to add login to our queries. 

Using a post routine, I entered api.php?action=login&lgname=username&lgpassword=password.

 

I retrieved the information including lgtoken.  I add lgtoken=… to the end of my query and receive the following error:

 

  <error code="unknown_action" info="Unrecognized value for parameter 'action': query" />

 

 

If I have “$wgGroupPermissions['*']['read'] = true” I receive no error. 

 

I have read about the login, and it looks like I may need to use cookies.  I would prefer not using cookies, but if I have to, I am not sure what to use. 

 

Thanks, 

 

Mary Beebe

 

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Gmane