Jump to content

API:ChangeContentModel

From mediawiki.org
MediaWiki version:
1.35

POST request to change the content model of a page.

API documentation

[edit]

action=changecontentmodel

(main | changecontentmodel)
  • This module requires read rights.
  • This module requires write rights.
  • This module only accepts POST requests.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Change the content model of a page

Specific parameters:
Other general parameters are available.
title

Title of the page to change the contentmodel of. Cannot be used together with pageid.

pageid

Page ID of the page to change the contentmodel of. Cannot be used together with title.

Type: integer
summary

Edit summary and log entry reason

tags

Change tags to apply to the log entry and edit.

Values (separate with | or alternative): AWB, convenient-discussions
model

Content model of the new content.

This parameter is required.
One of the following values: GadgetDefinition, Json.JsonConfig, JsonSchema, Map.JsonConfig, MassMessageListContent, NewsletterContent, Scribunto, SecurePoll, Tabular.JsonConfig, css, javascript, json, sanitized-css, text, translate-messagebundle, wikitext
bot

Mark the content model change with a bot flag.

Type: boolean (details)
token

A "csrf" token retrieved from action=query&meta=tokens

This parameter is required.
Example:
Change the main page to have the text content model
api.php?action=changecontentmodel&title=Main Page&model=text&token=123ABC [open in sandbox]


Example

[edit]

Making any POST request is a multi-step process:

  1. Log in, via one of the methods described on API:Login .
  2. GET a CSRF token .
  3. Send a POST request, with the CSRF token, to take action on a page.

The sample code below covers the final step in detail.

POST request

[edit]

Response

[edit]
{
    "changecontentmodel": {
        "title": "Main Page",
        "pageid": 123,
        "contentmodel": "text",
        "logid": 100,
        "revid": 200
    }
}

Possible errors

[edit]
Code Info
notoken The token parameter must be set.
missingtitle The page you specified doesn't exist. To create a new page with a custom content model, use the action=edit module.
nodirectediting $1 content model does not support direct editing
nochanges No changes were requested.
cannotbeused $1 content model cannot be used on $2
cannot-convert Could not convert $1 to $2 content model

See also

[edit]