I implemented a custom REST resource using this wiki. And I am having the following error whenever I try the doGetAll
and doSearch
endpoints.
{ "error": { "message": "[converting class org.openmrs.module.crudexample.Item to org.openmrs.module.webservices.rest.web.representation.RefRepresentation@269913fc]", "code": "org.openmrs.module.webservices.rest.web.ConversionUtil:409", "detail": }
Here are the methods.
@Override
protected NeedsPaging<Item> doGetAll(RequestContext context) {
return new NeedsPaging<Item>(exampleService.getAllItems(), context);
}
@Override
protected PageableResult doSearch(RequestContext context) {
String query = context.getParameter("q");
List<Item> itemsByQuery = null;
if (query != null) {
itemsByQuery = exampleService.getItems(query, false);
} else {
itemsByQuery = exampleService.getAllItems();
}
return new NeedsPaging<Item>(itemsByQuery, context);
}