wiki:RestApi

Version 2 (modified by jri, 13 years ago) (diff)

Get topic by ID

DeepaMehta REST API

The DeepaMehta application service is accessible via a REST API.

About the REST API:

All requests return application/json data.

For requests that take data in the request body: The data is expected to be of type application/json as well. So, 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).

About the curl examples:

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 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.

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.

Topics

Get topic by ID

Request

GET /core/topic/<topic ID>[?fetch_composite=true/false]

The default for fetch_composite is true.

Curl example 1: getting a topic with its composite value:

curl localhost:8080/core/topic/55 | jsonpretty

Response

{
  "id": 2676,
  "uri": "",
  "type_uri": "dm4.notes.note",
  "value": "What is DeepaMehta?",
  "composite": {
    "dm4.notes.title": "What is DeepaMehta?",
    "dm4.notes.text": "<p>DeepaMehta is a Post-Desktop-Metaphor user interface.</p>"
  }
}

Curl example 2: getting a topic without its composite value:

curl localhost:8080/core/topic/55?fetch_composite=false | jsonpretty

Response

{
  "id": 2676,
  "uri": "",
  "type_uri": "dm4.notes.note",
  "value": "What is DeepaMehta?",
  "composite": {
  }
}

For details about the topic data format see DataFormat#topic.

If the topic doesn’t exist an error 500 Retrieving topic xy failed is returned. (The error response might become more HTTP/REST conform in the furure.)