Search code examples
mediawikiwikipediawikipedia-apimediawiki-api

Wikimedia login doesn't give back token


Im starting experimenting with Wikimedia, but I somehow can't get the login request working with a HTTP Client (RESTClient Firefox and others). This should be fairly simple, but it seems to fail or I have overlooked something evident.

I am using the instructions from this site.

This is what I insert in RESTClient:

enter image description here

I don't get the MediaWiki API Result back, but the help page (see below). What am I doing wrong here? Thanks for any input.

Status Code: 200 OK
Cache-Control: private
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 38052
Content-Type: text/html; charset=utf-8
Date: Mon, 09 Jul 2012 11:50:51 GMT
MediaWiki-API-Error: help
Server: Apache
Vary: Accept-Encoding
X-Cache: MISS from sq33.wikimedia.org, MISS from amssq35.esams.wikimedia.org, MISS from amssq39.esams.wikimedia.org
X-Cache-Lookup: MISS from sq33.wikimedia.org:3128, MISS from amssq35.esams.wikimedia.org:3128, MISS from amssq39.esams.wikimedia.org:80
X-Content-Type-Options: nosniff


<!DOCTYPE HTML>
<html>
<head>
    <title>MediaWiki API</title>
</head>
<body>
<pre>
<span style="color:blue;">&lt;?xml version=&quot;1.0&quot;?&gt;</span>
<span style="color:blue;">&lt;api servedby=&quot;mw67&quot;&gt;</span>
<span style="color:blue;">&lt;error code=&quot;help&quot; info=&quot;&quot;
xml:space=&quot;preserve&quot;&gt;</span>

Solution

  • The are two problems with your request:

    1. You're using the wrong URL. The correct domain is en.wikipedia.org, not www.wikipedia.org.
    2. It seems RESTClient is using the Content-Type of text/plain by default, but the API expects application/x-www-form-urlencoded.

    If you correct those two problems, you will get the correct response.

    You also might want to indicate in what format do you want the response, by adding format=xml or format=json to the request. The default is HTML-formatted XML, which is useful for showing in a browser, but not for consumption by your application.