How to access OpenMRS REST API ?

Hi,

I have done the setup of OpenMRS on my local machine (V 1.12) and also I have added WEB REST Service module (V 2.11).

The issue is I am not able to call any REST API of OpenMRS except session. For each call I am getting unknown resource /ve/person. I tried using both i.e adding basic authentication as well as adding session id in cookie but getting the same response

Please let me know how to access these URLs ?

What’s the status_code for the response you get?

URL : http;//localhost:8080/openmrs/ws/rest/v1/person

Status : 500
Status Text : "Internal Server Error"
Error:ERROR - BaseRestController.handleException(90) |2015-07-07 22:01:38,414| Unknown resource: v1/person
org.openmrs.api.APIException: Unknown resource: v1/person
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImpl.getResourceByName(RestServiceImpl.java:391)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at org.openmrs.aop.LoggingAdvice.invoke(LoggingAdvice.java:125)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at com.sun.proxy.$Proxy105.getResourceByName(Unknown Source)
        at org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.get(MainResourceController.java:153)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)

Hi @waheedtechblog Can we know what you are aiming at meaning what data are you looking for Example: if you want to get all patients starting with say ‘ja’ then the url shall go like http://localhost:8080/openmrs/ws/rest/v1/person?q=“hi” and may be ask.openmrs is right place for these questions :slight_smile:

The issue is that there is no released version of the webservices.rest module that can run against the master branch of openmrs-core. Specifically, the last released version of webservices.rest only declares that its resources work up to “1.11.*”.

(Note that openmrs-core does not have a released version “1.12”, rather this is the master branch, that is “1.12-SNAPSHOT”.)

Your options are:

  1. Use a released version of openmrs-core
  2. Get the snapshot of the webservices.rest module (which will include this commit)
1 Like

Did you take a look at Rest Web Services API for Clients ?