in reply to Error accessing MediaWiki API

OK, here are more pieces to the puzzle. The issue is not yet resolved so I would still appreciate input on this.

I did more searches through MediaWiki docs and ultimately ended up on the MediaWiki IRC channel ( With the help from those guys, I found the following:

My conclusion is that despite setting the agent to 'Mozilla/5.0' the program is still not acting enough like a browser. My naive assessment is that the server is rejecting the request because it looks too much like a bot, but the functionality is available because the same request from a browser works.

So my question becomes: How do I make the program look more like a browser? Did I miss something in the headers? I can post more information if requested, but I don't know what to look for.

My dear monks, what am I missing?


Replies are listed 'Best First'.
Re^2: Error accessing MediaWiki API
by Anonymous Monk on Mar 29, 2009 at 07:25 UTC
    The headers may have been equivalent, but they weren't identical. The missing piece is the Accept header.

    rfc2616 says: If no Accept header field is present, then it is assumed that the client accepts all media types.

    It will work if you add headers to say that explicitly

    $mw->{ua}->default_header('Accept' => "*/*");
    This is clearly a bug with that webserver, it doesn't implement HTTP/1.x as it claims.

      Bingo! That did the trick. Thank you very much for your insight. You made my day. :-)