API:Import

POST request to import a page from another wiki(transwikiing) or from an xml file.

Examples
Importing a page is a multi-step process:   Log in using one of the methods described in .   GET a. This token is the same for all pages but changes at every login.

  Send a POST request with the CSRF token in order to import the page.  

The code samples below cover the third step in detail.

Sample Code
For simplicity, the following code is reading the XML from a textarea and makes use of MediaWiki's JavaScript includes.

This is just a minimal implementation.

Do not forget error-handling.

If you have the exports as files for upload and want to make it working in older browsers not sufficiently supporting Blobs and FormData, just build a HTML form.

The form's target could be an iframe so you can read the response from it without exposing the blank API result page to your users.

Ruby source code example using httpclient (assumes login cookies are already in @headers).

Possible errors
In addition to :

Parameter history

 * v1.29: Introduced  
 * v1.20: Introduced <tvar|1> </>

Additional notes

 * This module cannot be used as a.


 * <tvar|1> </> rights are required in order to upload an xml file, while <tvar|2> </> rights are required for interwiki imports.


 * If you get a  error, it is because you sent it url-encoded but claimed it would be multipart/form-data.  MediaWiki is looking for a boundary in the header but cannot find it.


 * Parameters marked with <tvar|1> </> are only used when importing an uploaded XML file. Similarly, parameters marked with <tvar|1> </> are only used when importing from another wiki (transwiki).

If the list of possible values for this parameter is empty, interwiki imports are disabled.
 * The possible values for the <tvar|1> </> parameter differ per wiki, see <tvar|2></>.