pages/{pageid}/diff (GET)
Overview
Show changes between revisions
- REST Method: GET
- Method Access: public
Uri Parameters
Name | Type | Description |
pageid | string | either an integer page ID, "home", or "=" followed by a double uri-encoded page path |
Query Parameters
Name | Type | Description |
authenticate | bool? | Force authentication for request (default: false) |
diff | {combined, all}? | Result format; 'combined' shows changes to the page contents, 'all' shows in addition the before and after versions of the page with highlighted changes; default is 'combined' |
previous | string? | Previous page revision to retrieve. 'head' by default will retrieve latest revision. Positive integer or a TimeUUID will retrieve specific revision |
format | {html, xhtml}? | Result format (default: html) |
mode | {edit, raw, view}? | which rendering mode to use when diffing; default is 'edit' |
revision | string? | Page revision to retrieve. 'head' by default will retrieve latest revision. Positive integer or a TimeUUID will retrieve specific revision |
redirects | int? | If zero, do not follow page redirects. |
Return Codes
Name | Value | Description |
OK | 200 | The request completed successfully |
Bad Request | 400 | Invalid input parameter or request body |
Forbidden | 403 | Read access to the page is required |
Not Found | 404 | Requested page could not be found |
Message Format
Output:
<content type="{contenttype}">{text}</content>
Implementation Notes
Setting Previous/Revision=1 refers to the earliest revision, 2 refers to the next earliest revision, and so on. Similarly, Previous/Revision=-1 refers to the revision prior to the current, -2 refers to the revision two prior to the current, and so on.
This feature uses the ViewNoExecute mode output from GET:pages/{pageid}/contents to perform the diff comparison.
C# Code Sample: Retrieve Page Diffs
The following code example performs a diff between the current and previous revisions of the page called "Page_Title":
Sample Code
Plug p = Plug.New("http://deki-hayes/@api/deki"); p.At("users", "authenticate").WithCredentials("admin", "password").Get(); p.At("pages", "=Page_Title", "diff").With("revision", "head").With("previous", -1).Get();
Sample Response from executing Code
Sample response indicating that the word "original" was deleted and the word "new" was added:
<content type="application/x.deki0702+xml"> <p> <ins>new</ins> <del>original</del> text </p> </content>
Implementation notes
Add notes about requirements or config values
Curl Code Sample: Retrieve Page Diffs
The following command generates a diff of the head (or current) revision of page "foo" and compares it to the previous revision. Note that the address is placed in quotes since the & character is reserved (at least in Windows cmd console).
Sample Code
curl -u username:password -i "http://mindtouch.address/@api/deki/pages/=foo/diff?revision=head&previous=-1"
Sample Response from executing Code
Head version: I am the Joker
Previous version: I am the Batman
<content type="application/x.deki-text"> <p>Home of the <ins>Joker</ins><del>Batman</del></p> <!-- Joker string inserted, Batman string removed --> </content>
Implementation notes
curl flags
- -u
- Provides external user authentication. Note that if anonymous access is available and authentication is not forced, this flag may be omitted.
- -i
- Outputs the HTTP response headers. Useful for debugging.
Revision rules
- Setting Previous/Revision=1 refers to the earliest revision, 2 refers to the next earliest revision, and so on. Similarly, Previous/Revision=-1 refers to the revision prior to the current, -2 refers to the revision two prior to the current, and so on.