This page documents the API for modifying PmWiki pages via the wiki engine (i.e. via
Sending a request to write to a page
The following fields may occur in a request to write to a wiki page.
Summarizing the requirements to post an update to a page.
Writing a page to the wiki via the wiki engine, i.e. via
The two fields
Additional fields such as
If the page is password protected, the browser must either have been previously authenticated (via a PHP session cookie) or otherwise send the appropriate credentials to allow edit access to the page. Normally the credentials are given by the 'authpw' and 'authid' fields:
Simultaneous edits are handled by the field '
When the form is submitted, if the last modification time of the page is greater than the basetime in the form, we know that the page changed somehow after the author requested the edit form. (The basetime also tells PmWiki which version of the page was "current" when the edit form was requested, so it can figure out how to merge the changes together.)
If a page is changed after a form's basetime, then instead of saving the page PmWiki sends back a new edit form with any merged changes and a note to the author to review the page for conflicts and submit again.
I think this "note" should be accompanied with something that's well specified, so as to make it easier for an external script to handle this situation. /Christian
If a client sends a post request that doesn't include a '
A successful request to save a page generally results in a 302 HTTP response, telling the browser to view the (newly saved) page. If a request to save a page fails, generally PmWiki returns a new edit form along with messages indicating why the page could not be saved.
I think some formal method is needed to report that a save has been blocked. The reason for the block might be a requirement for an author name, or that blocklist don't like it. There should be an API to detect this in any case. /Christian
Sending a request to upload a file to a page
The following fields may occur in a request to upload a file attachment to a wiki page.
Using curl to create a wiki page one would:
curl -d "?n=Main.WikiSandbox&text=TestingWiki&action=edit&post=1&author=AuthorName" http://localhost/pmwiki.php/Main/WikiSandbox
Note: the value for 'text' is assumed to already be urlencoded e.g. %20 for space.
Using curl to upload a file called testing.txt to the SandBox page one would:
curl -F n=Main.WikiSandbox -F action=postupload -F uploadfile=@/c/testing.txt -F upname=alt-name.txt http://localhost/pmwiki.php/Main/WikiSandbox
Note: The AT (@) character before the file is required.
Notification of problems
In response to a post by Christian, Patrick wrote on 2006-03-09
Sure, I can probably add that somewhere -- likely a comment in the <head> section. The other thing to look for is that a successful post always results in a redirect (i.e., status 302 or 301 or something), while an unsuccessful post results in a 200.
Accessing a password protected page
From Patrick in post on the PmWiki user's list on 2007-06-28.
> If you're using curl as a command-line tool, try the -d option: > > curl -d authpw=banana http://my.wiki.org/ProtectedGroup.DataPage > > This generates a POST request for the page, exactly as if someone > had filled in the authorization form.
Categories: PmWiki Developer