API:ChangeContentModel

From mediawiki.org
This page is a translated version of the page API:ChangeContentModel and the translation is 100% complete.
MediaWiki版本:
1.35

使用POST请求以變更頁面內容模型。

API帮助文档



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): convenient-discussions, possible vandalism, repeating characters
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]

示例

发出任何POST请求都是一个多步骤的过程:

  1. 使用API:登录 中描述的方法之一登录。
  2. 获取CSRF令牌


  3. 发送带有CSRF令牌的POST请求以在页面上执行操作。

下面的示例代码详细介绍了最后一步。

POST请求


回應

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

可能的错误

代码 信息
notoken token参数必须被设置。
missingtitle 您指定的页面不存在。要使用自定义内容模型创建新页面,请使用action=edit模块。
nodirectediting $1内容模型不支持直接编辑
nochanges 没有请求的更改。
cannotbeused $1内容模型不能用于$2
cannot-convert 无法将$1转换为$2内容模型

参见