Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleHTTP Header: Accept
Note: You must set your request header's "Accept" property to either JSON (application/json) or XML (application/xml) depending on the format you prefer to work with. 

Example usage from command line in XML format with pretty printing:

curl -s -H "Accept: application/xml" http://localhost:8080/rest/communities | xmllint --format -

For this documentation, we will assume that the URL to the "REST" webapp will be http://localhost:8080/rest/ for production systems, this address will be slightly different, such as: http://demo.dspace.org/rest/. The path to an endpoint, will go after the /rest/, such as /rest/communities, all-together this is: http://localhost:8080/rest/communities

...

Configuration for DSpace REST

You can configure if you want the DSpace REST to count views to a Community, Collection, Item or Bitstream as a Usage Event in the DSpace Statistics engines. Typically, when an object is viewed in a DSpace UI, that counts as a view or download, so that you can measure usage. If you would like views facilitated by the REST API to count, then configure the "stats" config to be true. To disable REST view's from counting in statistics, then set "stats" to false. 

In: dspace-source/dspace/config/modules/rest.cfg
Code Block
languagejava
# record stats in DSpace statistics module
stats = true

Propertystats
Example Valuetrue
Informational NoteBoolean value indicates whether statistics should be recorded for access via the REST API; Defaults to 'false'.

Recording Proxy Access by Tools

For the purpose of more accurate statistics, a web-based tool may specify who is using it, by adding parameters to the request:

Recording of statistics for view of items or download of bitstreams (set stats = true in rest.cfg to enable stats recording)
Code Block
http://localhost:8080/rest/items/:ID?userIP=ip&userAgent=userAgent&xforwarderfor=xforwarderfor

If no parameters are given, the details of

httprequest

the HTTP request's sender are used in statistics. This enables tools to record the details of their user rather than themselves.

Deploying the DSpace REST API in your Servlet Container

The dspace-rest module is automatically configured to compile and build with DSpace 4.0, so a mvn+ant process will create the webapp. To make it work in your environment, you would just need to add a context entry for it in your servlet container. For example, in tomcat, one might alter tomcat$CATALINA_homeHOME/conf/server.xml and add:

Code Block
languagexml
<Context path="/rest" docBase="/dspace/webapps/rest"

...

/>

Additional Information

Additional information can be found in the README for dspace-rest, and in the GitHub Pull Request for DSpace REST (Jersey).

...