Jump to content

Topic on Manual talk:How to debug/Login problems

Post request trouble (mwapi bot)

7
Summary by MvGulik

Local code troubles combined with a unexpected api-path change. ('/api.php' vs '/w/api.php')

See: [Special:SpecialPages >> Special:Version >> "Entry point URLs"] for active api path.

MvGulik (talkcontribs)

Been using mwapi for bot related stuff as admin on some MW-wiki. (I'm not hosting it, nor do I have any experiences in hosting or running MW.)But after some MW update of the site it seems I can't do any Post request anymore. (preventing properly logging).The thing it that I do not get an api error message. But MW response with the general MediaWiki API help "This is an auto-generated MediaWiki API documentation page." html page (so triggering a "Could not decode as JSON" code error). This suggest to me the problem resides at the MW-site.Not sure if this might be related to the potential updating process that was used by the host.Anything I can try or test so collect more info on this. (before contacting the host)(I know how to create a raw html/api:get request. Not sure how to format a raw html/api:post request though.)

MediaWiki: 1.39.10PHP: 8.1.30 (apache2handler)MariaDB: 11.5.2-MariaDB-ubu2404ICU: 72.1

Crap: While switching edit mode to preview the message the text got suddenly compressed. (not going to fight the editor anymore. If it thinks this is better. Ok, fine by me. (+and no more previewing on my part ofc)

Tgr (WMF) (talkcontribs)

Sounds like an URL routing problem (wrong Apache rewrite rule or such). You could try doing some requests via Special:ApiSandbox just to make sure the problem is not on your side.

MvGulik (talkcontribs)

ApiSandbox works ok, as I could create(edit) a new page with it.

The "URL routing problem" reminds me that the related wiki also switched to a Cloudflare server. Which did trigger some odd loosing-login-state issues on image pages. If it is a potential URL routing problem on my end, I'm not sure if ApiSandbox would also trigger them in that case.

(still working(cleaning) on my code, as I currently can't positively rule out it not being the problem. Although it used to work ok before the wiki's MW-updates & Cloudflare server switch.)

+(Hmm. I should run some login tests on some other wiki's for comparison.)

MvGulik (talkcontribs)

Took some time to add support for easier switching between wiki's & accounts.

Api login on "mediawiki.org" & "publictestwiki.com" work as expected. Login successful. (Main-user login and Bot-Passwords(Both old & newer style)).

But on the intended target wiki ... no joy, still failing with the same error. ... Guess its time to contact the host.

(OAuth mode login a bit outside my skill/knowledge/motivation level)

MvGulik (talkcontribs)

Humbug ... I noted that the target wiki failed on getting a login token, while in earlier testing that part completed successful. But than failed at the actual login part.

So, as I had some api-path troubles in earlier testing ... I changes the api path (now globally set!) from '/w/api.php' to '/api.php'. And now its back to working order. No wonder I got lost, never expected something like that. (+my code is a bit messy, which did not help.)

Problem solved I guess. (at least on my end .. for now)

Tgr (WMF) (talkcontribs)

You can find out the path from Special:Version, FWIW.

MvGulik (talkcontribs)

... Aha. Don't recall seeing, on the target wiki, the "Entry point URLs" section before though. Although that's probably because that very selective memory of mine. ;-)