Changes between Version 3 and Version 4 of RestApi
- Timestamp:
- 03.09.2011 01:02:37 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
RestApi
v3 v4 14 14 **About the curl examples:** 15 15 16 The curl examples are ready for being pasted into a terminal. However, in order to get reasonable results you should adjust the IDs and example valuesto your actual DB content. Hint: to determine a topic's or association's ID click it in the webclient and read the console log.16 The curl examples are ready for being pasted into a terminal. However, the IDs must be adjusted to your actual DB content. Hint: to determine a topic's or association's ID click it in the webclient and read the console log. 17 17 18 18 In order to make the responses more readable the curl examples make use of the `jsonpretty` tool. Jsonpretty is installable as a Ruby gem. See http://github.com/nicksieger/jsonpretty. … … 22 22 === Get topic by ID === 23 23 24 **Request**25 26 24 {{{ 27 25 GET /core/topic/<topic ID>[?fetch_composite=true/false] … … 30 28 The default for `fetch_composite` is `true`. 31 29 32 Curl example 1: getting a topic ''with'' its `composite` value: 30 ==== Example 1: Getting a topic ''with'' its `composite` value ==== 33 31 34 32 {{{ … … 36 34 }}} 37 35 38 **Response** 36 Response: 39 37 40 38 {{{ 39 HTTP/1.1 200 OK 40 Content-Type: application/json 41 41 42 { 42 43 "id": 2676, … … 46 47 "composite": { 47 48 "dm4.notes.title": "What is DeepaMehta?", 48 "dm4.notes.text": "<p>DeepaMehta is a Post-Desktop-Metaphor user interface.</p>"49 "dm4.notes.text": "<p>DeepaMehta is a think tool.</p>" 49 50 } 50 51 } 51 52 }}} 52 53 53 Curl example 2: getting a topic ''without'' its `composite` value: 54 For details about the topic data format see DataFormat#topic. 55 56 ==== Example 2: Getting a topic ''without'' its `composite` value ==== 54 57 55 58 {{{ … … 57 60 }}} 58 61 59 **Response** 62 Response: 60 63 61 64 {{{ 65 HTTP/1.1 200 OK 66 Content-Type: application/json 67 62 68 { 63 69 "id": 2676, … … 70 76 }}} 71 77 72 For details about the topic data format see DataFormat#topic.73 74 78 If the topic doesn’t exist an error `500 Retrieving topic xy failed` is returned. 75 79 (The error response might become more HTTP/REST conform in the furure.) 76 80 77 81 === Create topic === 78 79 **Request**80 82 81 83 {{{ … … 85 87 }}} 86 88 87 Curl example: 89 ==== Example 1: Creating a simple topic ==== 88 90 89 91 {{{ 90 curl -X POST -H Content-Type:application/json -d ' 91 {type_uri: "dm4.notes.note", 92 composite: {dm4.notes.title: "My title", dm4.notes.text: "My text"} 93 }' localhost:8080/core/topic 92 curl localhost:8080/core/topic -i \ 93 -X POST \ 94 -H Content-Type:application/json \ 95 -d '{type_uri: "dm4.contacts.city", value: "Port-au-Prince"}' \ 96 | jsonpretty 94 97 }}} 95 98 96 99 For details about the topic data format see DataFormat#topic. 97 100 98 **Response** 101 Response: 102 103 {{{ 104 HTTP/1.1 200 OK 105 Content-Type: application/json 106 107 { 108 "id": 3448, 109 "uri": "", 110 "type_uri": "dm4.contacts.city", 111 "value": "Port-au-Prince", 112 "composite": { 113 } 114 } 115 }}} 116 117 ==== Example 2: Creating a complex topic ==== 118 119 {{{ 120 curl localhost:8080/core/topic -i \ 121 -X POST \ 122 -H Content-Type:application/json \ 123 -d '{type_uri: "dm4.notes.note", 124 composite: { 125 dm4.notes.title: "My title", 126 dm4.notes.text: "<p>My test text here<p>"}}' \ 127 | jsonpretty 128 }}} 129 130 Response: 99 131 100 132 {{{ … … 109 141 "composite": { 110 142 "dm4.notes.title": "My title", 111 "dm4.notes.text":" My text"143 "dm4.notes.text":"<p>My test text here<p>" 112 144 } 113 145 }