Create new page via REST API on behalf of other users

Hi all,
First of all, thanks for creating and supporting such great software as XWiki!
I’m trying to migrate our old wiki system from Mindtouch to XWiki and I came across few problems.

I decided to create pages through the REST API but I’m unable to assign their ownership and some other properties to the data I send.

For example I send following PUT request to http://localhost:8500/rest/wikis/xwiki/spaces/Sandbox/pages/test with basic authentication. I’d like this new test page to be seen as created by user on specified created date (this user exists in the system).

<?xml version="1.0" encoding="utf-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.xwiki.org">
	<name>Test</name>
	<title>Test</title>
	<author>XWiki.user</author>
	<authorName>XWiki.user</authorName>
	<majorVersion>0</majorVersion>
	<minorVersion>0</minorVersion>
	<hidden>false</hidden>
	<created>2017-02-22T17:14:10+01:00</created>
	<creator>XWiki.user</creator>
	<syntax>html/4.01</syntax>
	<creatorName>XWiki.user</creatorName>
	<modified>2017-02-28T12:19:29+01:00</modified>
	<comment>test</comment>
	<content>
	Hello World!
	</content>
</page>

Unfortunately, in response I get:

(...)
<created>2018-01-30T14:08:36Z</created>
<creator>XWiki.my_username</creator>
(...)

where my_username is obviously me.

Is there any way to override this properties with the data submitted in the request? If not - do you see any other way to import pages from other system?

The REST API does not allow this override, only the protected API allows it so you will need to pull data instead of pushing them.

The current standard way of importing data from another system is to implement a input filter for it. There is some general documentation on http://extensions.xwiki.org/xwiki/bin/view/Extension/Filter+Module but the best right now is to look at example listed on that page.

Basically the idea is to create a component which is given an output filter and configurable properties (can be pretty much anything) and translate the (in this case Mindtouch) data into generic SAX-like “events” (start a document, start an object, add an attachment, end a document). Then if someone wants to import Mindtouch data in a running instance of XWiki the generic Filter application can be used with “Mindtouch” as input and “XWiki Instance” as output.

1 Like

Thanks a lot for this clarification. I will look further into this input filter extension. Perhaps it would be possible to fork some of the existing modules to work with Mindtouch. Thanks again and have a great day!