Fetching a report to OWA through Reporting REST API

Hi everyone!

I have implemented some basic reports already working fine with reporting module. Now I’m trying to expose them through a Open Web App (OWA) module. The approach is to fetch the report that I want through making a REST call to Reporting REST API.

I have created an simple OWA. You can have a look at it here.

Below is the class which I am trying to fetch the data from the server. But I don’t get any results.

I would be much grateful to know any tips, advises about the way I’m trying to fetch the report through Reporting REST.:grinning:

Regards, Jude Niroshan

1 Like

As you can see from here: https://qa-refapp.openmrs.org/openmrs/module/webservices/rest/apiDocs.htm#!/reportingrest_reportRequest/getReportRequest the request should be like: https://127.0.0.1:8081/openmrs/ws/rest/v1/reportingrest/reportRequest/d3950d7c-4881-11e7-a919-92ebcb67fe33

For your case that means: this.fetchLocation(‘reportingrest/reportRequest/d3950d7c-4881-11e7-a919-92ebcb67fe33’).then((response) => { this.setState({ listOfUsersReport: response });

2 Likes

Hi @dkayiwa @raff ,

Thank you for helping me out. I didn’t know about the apiDocs for REST in OpenMRS. It’s really a useful tool for developers.

My goal is to retrieve a report result through reporting REST. In order to check whether I defined reports in my database, I ran the below http GET request.

http://localhost:8080/openmrs/ws/rest/v1/reportingrest/reportDefinition

It gave me all the reports which I have saved through reporting module. Now I need to get a specific report result.

So, based on the above result I received, I made the below http GET request to retrieve the report result.

http://localhost:8080/openmrs/ws/rest/v1/reportingrest/reportRequest/d3950d7c-4881-11e7-a919-92ebcb67fe33

But I am getting an error as the response.

{
  "error": {
    "message": "Object with given uuid doesn't exist [null]",
    "code": "org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource:53",
    "detail": "org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException\r\n\tat org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.retrieve(DelegatingCrudResource.java:53)\r\n\tat org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.retrieve(MainResourceController.java:75)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177)\r\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)\r\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:624)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:731)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\r\n\tat 
    ...

  }
}

Am I using a incorrect service to retrieve a report result? (the uuid which I am passing is the uuid for a report)

Regards, Jude Niroshan

FYI see full Reporting REST API documentation here: https://github.com/openmrs/openmrs-module-reportingrest/wiki