Fossil SCM
Added missing json-api/tips.md. Minor formatting tweak in the timeline docs.
Commit
6b1786659543cee2245a1350673697d2bc8336b9380c230b33ddeffa6e1da126
Parent
b833df21f799caa…
2 files changed
+3
-3
+54
+3
-3
| --- www/json-api/api-timeline.md | ||
| +++ www/json-api/api-timeline.md | ||
| @@ -21,14 +21,14 @@ | ||
| 21 | 21 | and whatnot). |
| 22 | 22 | |
| 23 | 23 | By default the entries are returned in chronological order from newest |
| 24 | 24 | to oldest, but some options might change that. |
| 25 | 25 | |
| 26 | -FIXME (20120623): we have some inconsistent "type" vs. "eventType" in | |
| 27 | -the result sets. "type" is the current preferred choice (and it seems | |
| 26 | +FIXME (20120623): we have some inconsistent `type` vs. `eventType` in | |
| 27 | +the result sets. `type` is the current preferred choice (and it seems | |
| 28 | 28 | unlikely that `eventType` is actually used in any client code). We |
| 29 | -don't actually need either one (but a use for "type" is easily | |
| 29 | +don't actually need either one (but a use for `type` is easily | |
| 30 | 30 | envisioned), and we may get rid of both. |
| 31 | 31 | |
| 32 | 32 | **Common request options (via CLI, GET or POST.payload):** |
| 33 | 33 | |
| 34 | 34 | - `limit=integer` limits the number of entries in the response. Default |
| 35 | 35 | |
| 36 | 36 | ADDED www/json-api/tips.md |
| --- www/json-api/api-timeline.md | |
| +++ www/json-api/api-timeline.md | |
| @@ -21,14 +21,14 @@ | |
| 21 | and whatnot). |
| 22 | |
| 23 | By default the entries are returned in chronological order from newest |
| 24 | to oldest, but some options might change that. |
| 25 | |
| 26 | FIXME (20120623): we have some inconsistent "type" vs. "eventType" in |
| 27 | the result sets. "type" is the current preferred choice (and it seems |
| 28 | unlikely that `eventType` is actually used in any client code). We |
| 29 | don't actually need either one (but a use for "type" is easily |
| 30 | envisioned), and we may get rid of both. |
| 31 | |
| 32 | **Common request options (via CLI, GET or POST.payload):** |
| 33 | |
| 34 | - `limit=integer` limits the number of entries in the response. Default |
| 35 | |
| 36 | DDED www/json-api/tips.md |
| --- www/json-api/api-timeline.md | |
| +++ www/json-api/api-timeline.md | |
| @@ -21,14 +21,14 @@ | |
| 21 | and whatnot). |
| 22 | |
| 23 | By default the entries are returned in chronological order from newest |
| 24 | to oldest, but some options might change that. |
| 25 | |
| 26 | FIXME (20120623): we have some inconsistent `type` vs. `eventType` in |
| 27 | the result sets. `type` is the current preferred choice (and it seems |
| 28 | unlikely that `eventType` is actually used in any client code). We |
| 29 | don't actually need either one (but a use for `type` is easily |
| 30 | envisioned), and we may get rid of both. |
| 31 | |
| 32 | **Common request options (via CLI, GET or POST.payload):** |
| 33 | |
| 34 | - `limit=integer` limits the number of entries in the response. Default |
| 35 | |
| 36 | DDED www/json-api/tips.md |
+54
| --- a/www/json-api/tips.md | ||
| +++ b/www/json-api/tips.md | ||
| @@ -0,0 +1,54 @@ | ||
| 1 | +# JSON API: Tips and Tricks | |
| 2 | +([⬑JSON API Index](index.md)) | |
| 3 | + | |
| 4 | +Jump to: | |
| 5 | + | |
| 6 | +* [Beware of Content-Type and Encoding...](#content-type) | |
| 7 | +l` and `wget`](#curl-wget) | |
| 8 | +* [Example JavaScript](#javascript) | |
| 9 | +* [Demo Apps](#demo-apps) | |
| 10 | + | |
| 11 | +--- | |
| 12 | + | |
| 13 | +<a id="content-type"></a> | |
| 14 | +# Beware of Content-Type and Encoding... | |
| 15 | + | |
| 16 | +When posting data to fossil, make sure that the request sendsapplication/json. Fossil also (currently) | |
| 17 | + accepts `application/javascript` and `text/plain` as JSON input, | |
| 18 | + but `application/json` is preferred. The client may optionally | |
| 19 | + send `;charset=utf-8` with the Content-Type, but any other | |
| 20 | + encoding produces undefined results. Behaviour without the charset | |
| 21 | + or with `;charset=utf-8` suffix is identical. | |
| 22 | +- **POST data must be an non-form-encoded JSON string** | |
| 23 | + (ASCII or UTF-8). jQuery, by default, form-urlencodes it, which the | |
| 24 | + fossil json bits cannot read. e.g. post the result of | |
| 25 | + `JSON.stringify(requestObject)`, without any additional encoding on | |
| 26 | + top of it. | |
| 27 | +- **When POSTing via jQuery**, set these AJAX options: | |
| 28 | + - `contentType:'application/json'` | |
| 29 | + - `dataType:'text'` | |
| 30 | + - `data:JSON.stringify(requestObject)` | |
| 31 | +- **When POSTing via XMLHttpRequest** (XHR), be sure to: | |
| 32 | + - `xhr.open( … )` | |
| 33 | + - `xhr.setRequestHeader("Content-Type", "application/json")` | |
| 34 | + - `xhr.send( JSON.stringify( requestObject ) )` | |
| 35 | + | |
| 36 | +The response will be (except in the case of an HTTP 500 error or | |
| 37 | +similar) a JSON or JSONP string, ready to be parsed by your favourite | |
| 38 | +`JSON.parse()` implementation ohrefrm-encoded JSON string** | |
| 39 | + (ASCII or UTF-8). jQuery, by default, form-urlencodes it, which the | |
| 40 | + fossil json bits cannot read. e.g. post the result of | |
| 41 | + `JSON.stringify(requestObject)`, without any additional encoding on | |
| 42 | + top of it. | |
| 43 | +- **When POSTing via jQuery**, set these AJAX options: | |
| 44 | + - `contentType:'application/json'` | |
| 45 | + - `dataType:'text'` | |
| 46 | + - `data:JSON.stringify(requestObject)` | |
| 47 | +- **When POSTing via XMLHttpRequest** (XHR), be sure to: | |
| 48 | + - `xhr.open( … )` | |
| 49 | + - `xhr.setRequestHeader("Content-Type", "application/json")` | |
| 50 | + - `xhr.send( JSON.stringify( requestObject ) )` | |
| 51 | + | |
| 52 | +The response will be (except in the case of an HTTP 500 error or | |
| 53 | +similar) a JSON or JSONP string, ready to be parsed by your favourite | |
| 54 | +`JSON.parse()` implementati |
| --- a/www/json-api/tips.md | |
| +++ b/www/json-api/tips.md | |
| @@ -0,0 +1,54 @@ | |
| --- a/www/json-api/tips.md | |
| +++ b/www/json-api/tips.md | |
| @@ -0,0 +1,54 @@ | |
| 1 | # JSON API: Tips and Tricks |
| 2 | ([⬑JSON API Index](index.md)) |
| 3 | |
| 4 | Jump to: |
| 5 | |
| 6 | * [Beware of Content-Type and Encoding...](#content-type) |
| 7 | l` and `wget`](#curl-wget) |
| 8 | * [Example JavaScript](#javascript) |
| 9 | * [Demo Apps](#demo-apps) |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | <a id="content-type"></a> |
| 14 | # Beware of Content-Type and Encoding... |
| 15 | |
| 16 | When posting data to fossil, make sure that the request sendsapplication/json. Fossil also (currently) |
| 17 | accepts `application/javascript` and `text/plain` as JSON input, |
| 18 | but `application/json` is preferred. The client may optionally |
| 19 | send `;charset=utf-8` with the Content-Type, but any other |
| 20 | encoding produces undefined results. Behaviour without the charset |
| 21 | or with `;charset=utf-8` suffix is identical. |
| 22 | - **POST data must be an non-form-encoded JSON string** |
| 23 | (ASCII or UTF-8). jQuery, by default, form-urlencodes it, which the |
| 24 | fossil json bits cannot read. e.g. post the result of |
| 25 | `JSON.stringify(requestObject)`, without any additional encoding on |
| 26 | top of it. |
| 27 | - **When POSTing via jQuery**, set these AJAX options: |
| 28 | - `contentType:'application/json'` |
| 29 | - `dataType:'text'` |
| 30 | - `data:JSON.stringify(requestObject)` |
| 31 | - **When POSTing via XMLHttpRequest** (XHR), be sure to: |
| 32 | - `xhr.open( … )` |
| 33 | - `xhr.setRequestHeader("Content-Type", "application/json")` |
| 34 | - `xhr.send( JSON.stringify( requestObject ) )` |
| 35 | |
| 36 | The response will be (except in the case of an HTTP 500 error or |
| 37 | similar) a JSON or JSONP string, ready to be parsed by your favourite |
| 38 | `JSON.parse()` implementation ohrefrm-encoded JSON string** |
| 39 | (ASCII or UTF-8). jQuery, by default, form-urlencodes it, which the |
| 40 | fossil json bits cannot read. e.g. post the result of |
| 41 | `JSON.stringify(requestObject)`, without any additional encoding on |
| 42 | top of it. |
| 43 | - **When POSTing via jQuery**, set these AJAX options: |
| 44 | - `contentType:'application/json'` |
| 45 | - `dataType:'text'` |
| 46 | - `data:JSON.stringify(requestObject)` |
| 47 | - **When POSTing via XMLHttpRequest** (XHR), be sure to: |
| 48 | - `xhr.open( … )` |
| 49 | - `xhr.setRequestHeader("Content-Type", "application/json")` |
| 50 | - `xhr.send( JSON.stringify( requestObject ) )` |
| 51 | |
| 52 | The response will be (except in the case of an HTTP 500 error or |
| 53 | similar) a JSON or JSONP string, ready to be parsed by your favourite |
| 54 | `JSON.parse()` implementati |