[REST/WS] POSTing obsgroup via rest throws serialization error

Hi,

I get a funny error whenever I try POSTing an encounter with an obsGroup via rest. Below is a demo request body:

{
    "patient": "76761b1f-729b-45c9-82e1-f4a8eee1957a",
    "encounterDatetime": "2021-10-08T10:08:45.259Z",
    "location": "28066518-a0e5-4331-b23e-7b40f96d733a",
    "encounterType": "79c1f50f-f77d-42e2-ad2a-d29304dde2fe",
    "encounterProviders": [
        {
            "provider": "82252c2a-3d17-48c0-a739-881ba41d3341",
            "encounterRole": "240b26f9-dd88-4172-823d-4a8bfeb7841f"
        }
    ],
    "obs": [
        {
            "person": "76761b1f-729b-45c9-82e1-f4a8eee1957a",
            "obsDatetime": "2021-10-08T10:08:45.259Z",
            "concept": "8acba1d1-67cc-422c-961e-86d6b47bc45b",
            "location": "28066518-a0e5-4331-b23e-7b40f96d733a",
            "groupMembers": [
                {
                    "person": "76761b1f-729b-45c9-82e1-f4a8eee1957a",
                    "obsDatetime": "2021-10-08T10:08:45.259Z",
                    "concept": "d3205b6a-7192-461f-9ea8-a1ac8af38964",
                    "location": "28066518-a0e5-4331-b23e-7b40f96d733a",
                    "value": 100
                }
            ],
            "voided": false
        }
    ]
}

Error in response (Full server log)

om.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.springframework.validation.DefaultMessageCodesResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.openmrs.module.webservices.validation.ValidationException["errors"]->org.springframework.validation.BindException["bindingResult"]->org.springframework.validation.BeanPropertyBindingResult["messageCodesResolver"])
	com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
	com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1277)
	com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400)
	com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:71)
	com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:33)
	com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
	com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
	com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
	com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1516)
	com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1006)
	org.springframework.web.servlet.view.json.AbstractJackson2View.writeContent(AbstractJackson2View.java:228)
	org.springframework.web.servlet.view.json.AbstractJackson2View.renderMergedOutputModel(AbstractJackson2View.java:172)
	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)
	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
	org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:60)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:73)
	org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:65)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
	org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:105)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
	org.openmrs.module.webservices.rest.web.filter.ContentTypeFilter.doFilter(ContentTypeFilter.java:64)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
	org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:106)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
	org.openmrs.module.owa.filter.OwaFilter.doFilter(OwaFilter.java:93)
	org.openmrs.module.owa.filter.OwaFilter.doFilter(OwaFilter.java:61)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
	org.openmrs.module.spa.filter.SpaFilter.doFilter(SpaFilter.java:53)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
	org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:57)
	org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:105)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	org.springframework.orm.hibernate5.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:156)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:108)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:108)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:108)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

Server Props:

  • Platform: 2.4.0
  • Rest Web Services: 2.32.0-SNAPSHOT.2601f8

Is my request payload malformed?

cc: @dkayiwa, @ibacher

@samuel34 , does this happen for downgraded versions of Rest Web Services module?

No, I have tested this out in the demo environment and it works well.

{
    "patient": "3a84e9e3-bdce-4bd8-ae68-5c72987bcba2",
    "encounterDatetime": "2021-10-08T10:08:45.259Z",
    "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
    "encounterType": "e22e39fd-7db2-45e7-80f1-60fa0d5a4378",
    "encounterProviders": [
        {
            "provider": "f9badd80-ab76-11e2-9e96-0800200c9a66",
            "encounterRole": "240b26f9-dd88-4172-823d-4a8bfeb7841f"
        }
    ],
    "obs": [
        {
            "person": "3a84e9e3-bdce-4bd8-ae68-5c72987bcba2",
            "obsDatetime": "2021-10-08T10:08:45.259Z",
            "concept": "dcbf92f3-d4d7-45e9-8772-b3ff1fd1d04a",
            "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
            "groupMembers": [
                {
                    "person": "3a84e9e3-bdce-4bd8-ae68-5c72987bcba2",
                    "obsDatetime": "2021-10-08T10:08:45.259Z",
                    "concept": "f382ac4d-88f5-4eba-81e8-afaf67d5a5b4",
                    "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
                    "value": "129473AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                }
            ],
            "voided": false
        }
    ]
}

Openmrs’ Demo is running 2.32.0. This actually awakened me that the release for 2.32.0 was made. @amugume don’t you think we want to upgrade to the latest version?

cc: @eudson

We have installed the latest version of REST/WS (the same version running in demo) but the error persists.

Below are the modules installed on the server:

@dkayiwa any advice on how I would debug this?

@samuel34, could you also share, for more debugging info, the equivalent of this page https://demo.openmrs.org/openmrs/admin/maintenance/systemInfo.htm?

@ruhanga OpenMRS - Login (Same credentials as the demo site)

From your logs, it looks like a validation exception. Can you confirm that all the uuids that you are passing are pointing to existing objects?

1 Like

Hhhmm thanks Daniel, the issue was with my providerId.