Changes between Version 1 and Version 2 of RestApi


Ignore:
Timestamp:
02.09.2011 14:55:40 (9 years ago)
Author:
jri
Comment:

Get topic by ID

Legend:

Unmodified
Added
Removed
Modified
  • RestApi

    v1 v2  
    1 Documentation of the REST API 
     1[[PageOutline]] 
     2 
     3= DeepaMehta REST API = 
     4 
     5The DeepaMehta application service is accessible via a REST API. 
     6 
     7**About the REST API:** 
     8 
     9All requests return `application/json` data. 
     10 
     11For requests that take data in the request body: The data is expected to be of type `application/json` as well. 
     12So, don’t forget to set the request’s `Content-Type` header accordingly. Otherwise an error is returned (as `application/x-www-form-urlencoded` is used as the default). 
     13 
     14**About the curl examples:** 
     15 
     16The curl examples are ready for being pasted into a terminal. However, in order to get reasonable results you should adjust the IDs and example values 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 
     18In 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. 
     19 
     20== Topics == 
     21 
     22=== Get topic by ID === 
     23 
     24**Request** 
     25 
     26{{{ 
     27GET /core/topic/<topic ID>[?fetch_composite=true/false] 
     28}}} 
     29 
     30The default for `fetch_composite` is `true`. 
     31 
     32Curl example 1: getting a topic ''with'' its `composite` value: 
     33 
     34{{{ 
     35curl localhost:8080/core/topic/55 | jsonpretty 
     36}}} 
     37 
     38**Response** 
     39 
     40{{{ 
     41{ 
     42  "id": 2676, 
     43  "uri": "", 
     44  "type_uri": "dm4.notes.note", 
     45  "value": "What is DeepaMehta?", 
     46  "composite": { 
     47    "dm4.notes.title": "What is DeepaMehta?", 
     48    "dm4.notes.text": "<p>DeepaMehta is a Post-Desktop-Metaphor user interface.</p>" 
     49  } 
     50} 
     51}}} 
     52 
     53Curl example 2: getting a topic ''without'' its `composite` value: 
     54 
     55{{{ 
     56curl localhost:8080/core/topic/55?fetch_composite=false | jsonpretty 
     57}}} 
     58 
     59**Response** 
     60 
     61{{{ 
     62{ 
     63  "id": 2676, 
     64  "uri": "", 
     65  "type_uri": "dm4.notes.note", 
     66  "value": "What is DeepaMehta?", 
     67  "composite": { 
     68  } 
     69} 
     70}}} 
     71 
     72For details about the topic data format see DataFormat#topic. 
     73 
     74If the topic doesn’t exist an error `500 Retrieving topic xy failed` is returned. 
     75(The error response might become more HTTP/REST conform in the furure.)