Get the Code

You can build the module like any other mavenized module by doing an *mvn clean install *in the root module package.

Read the Conventions

The first thing to do is to read through the conventions section on the ﻿REST Web Services API For Clients. This outlines the very basics of the how to name the urls, design the objects, etc.

Note: When creating a REST resource and sub-resource URI and name respectively, the absolute and relative path names should be written in all-lowercase ASCII letters. Avoid capital letters, camel caps to mention a few. The norm is to use lower case letters.

Example:

/ws/rest/v1/conceptclass

Testing a URL

Through the webapp

With the webservices.rest module installed, there is a Test page linked to from on the Administration page.

From this page you can make jquery POST/PUSH/GET/DELETE web servces calls to the server and see the results.

The default values are to do a GET on a person. Check your database for a valid person UUID and try the query. (The post data does not matter in this case)

From command line with CURL

A valid curl call with authentication:

Adding new Web Service URLs

Icon

Our best-practices may change over the course as we learn new things, but ConceptResource1_8 should always be an up-to-date best-practice example that you can use as a pattern.

This example will use the Location object in the OpenMRS API.

Create a new LocationResource1_8 object for the object (note the 1_8 postfix indicating the lowest version of OpenMRS this resource can work with)
See also code for LocationResource1_8

The resource objects are used for the automatic translation into json/xml.

In the org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8 package, create a new class that extends MetadataDelegatingCrudResource<Location>.