Rest API error calling obs resource endpoint

I have a python script and I am trying to make a call to http://localhost:8080/openmrs/ws/rest/v1/obs?v=default over basicauth with application/json as accept and content-type headers. I am getting the following:

"The Resource Does not Support the Requested Operation [null]"

Full Response { "error": { "message": "The Resource Does not Support the Requested Operation [null]", "code": "org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource:226", "detail": "org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException\n at org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.doGetAll(DelegatingCrudResource.java:226)\n at org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.getAll(DelegatingCrudResource.java:213)\n at org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.get(MainResourceController.java:201)\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:606)\n at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)\n at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)\n at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)\n at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)\n at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)\n at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)\n at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)\n at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)\n at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)\n at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:61)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:72)\n at org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:64)\n at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\n at org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:104)\n at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\n at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:73)\n at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\n at org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:54)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:109)\n at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:230)\n at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)\n at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)\n at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)\n at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)\n at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)\n at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)\n at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)\n at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)\n at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)\n at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)\n at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)\n at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)\n at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)\n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)\n at java.lang.Thread.run(Thread.java:748)\n" } }

I appreciate any pointers.

Thanks

@mwebazem,

Can you find your answer at rest.openmrs.org? If not, what information is missing?

/cc @saurabh, @ayesh

1 Like

@mwebazem I saw obs section of the documentation here and I figured out that we need to query for observations based on either patient UUID or concept UUID . so I listed down all the concepts

https://admin:Admin123@qa-refapp.openmrs.org/openmrs/ws/rest/v1/concept

chose one of the UUID and then made a call to the obs endpoint which retured empty results (maybe because no observations associated with that concept yet)

https://admin:Admin123@qa-refapp.openmrs.org/openmrs/ws/rest/v1/obs?concept=18316c68-b5f9-4986-b76d-9975cd0ebe31

demo server is down so I used qa-refapp server.

Thanks @saurabh using a concept query parameter does work. However from the Swagger generate documentation (see below), it isn’t really clear that the query parameters concept or concepts are required? Is there a way I can just return all obs?

https://demo.openmrs.org/openmrs/module/webservices/rest/apiDocs.htm

1 Like

@mwebazem I am not so sure but It might be a necessary param to work with obs endpoint cc @gcliff

Hi @burke

Yes we can retrieve all the observations

Normally if you want to retrieve all the results use the query option with all flag.

curl -X GET "https://demo.openmrs.org/openmrs/ws/rest/v1/obs?q=all"

To answer y oure other question please have a look at the obs class in core below.

As you can see normally an observation can have a concept.

Please go through below doc as well. https://rest.openmrs.org/#observations

@saurabh this is not the case you can’t directly concept uuid to retrieve an observation u should pass the patient id and with it u can pas concept id as well.

Btw @burke it seems like the swagger is very outdated. I am not sure why am not seeing the patient attribute but the person attribute in the core class

1 Like

I don’t know if asking for all observations (for all patients) would be supported. If supported, it could take down a server, since some implementations have up to 100 million observations or more.

Hi @burke

Yes we can retrieve all the observations

Normally if you want to retrieve all the results use the query option with all flag. But yeah as @burke mentioned it’s not good to use the all query always it’s a heavy query ofcourse with 1000nds of data. If using use a limit.

curl -X GET "https://demo.openmrs.org/openmrs/ws/rest/v1/obs?q=all"

@mwebazem To answer youre other question please have a look at the obs class in core below.

As you can see normally an observation can have a concept.

Please go through below doc as well. https://rest.openmrs.org/#observations

@saurabh this is not the case you can’t directly concept uuid to retrieve an observation u should pass the patient id and with it u can pas concept id as well.

for an example in the demo server please use the below curl command

curl -X GET "https://demo.openmrs.org/openmrs/ws/rest/v1/obs?v=default&patient=90f7f0b4-06a8-4a97-9678-e7a977f4b518&concept=5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -H "accept: application/json" -H

Btw @burke it seems like the swagger is very outdated. I am not sure why am not seeing the patient attribute but the person attribute in the core class

2 Likes

yes @ayesh I tried it, it works and returns a hugeeee list !!

exactly as @burke mentioned there can be lot of observations. Not good to use it always :smile:

1 Like

Thanks this is what I needed…the query parameter q = ‘all’ did it. Thanks for your help. The swagger documentation is a good starting point but it isn’t clear on what values q can take on.

Yes will take a note on this

cc :- @saurabh

1 Like