I'd like to create a new page in a MediaWiki via the API. According to the documentation this should be accomplished by setting the action
to edit
and then specifying a set of parameters, e.g. like this:
bot = false
contentformat = "text/x-wiki"
contentmodel = "wikitext"
createonly = false
minor = true
nocreate = false
recreate = true
summary = ""
text = "........"
title = "SomeTitle123"
And of course the CSRF-token.
However if I try to create a page using these parmeters I get the following error response:
code: "missingtitle"
info: "The page you specified doesn't exist."
It seems that in contrast to the API documentation the API rejects my attempt to create a page. What am I missing here? How is it possible to create a new page in MediaWiki using the API?
Basically the data specified in the question is already the correct data to send to the API for creating a new wiki page.
Unfortunately a simple but very important detail has to be considered: The MediaWiki API recognizes boolean variables not by their value but by their presence. That means: If you specify nocreate = false
literally in your data structure that means nocreate = true
for the API.
The correct way to specify data for the MediaWiki API is to leave out any boolean variable that contains false
.
Therefore the correct data to send to the API is the following:
contentformat = "text/x-wiki"
contentmodel = "wikitext"
minor = true
recreate = true
summary = ""
text = "........"
title = "SomeTitle123"