Using HAPI FHIR Models in restful API request?

I am working on developing a Spring boot mddleware that sends the response from the fhir server to the frontend and vice versa. I am getting the following error when i try to use HAPI Fhir object to send or receive response.

1.Sending FHIR Object as response

Following API send RelatedPerson FHIR resource as the response. Calling this API results in the following error:

Resolved [org.springframework.http.converter.HttpMessageNotWritableException:
Could not write JSON: Infinite recursion (StackOverflowError);
nested exception is com.fasterxml.jackson.databind.JsonMappingException:
Infinite recursion (StackOverflowError) (through reference chain: org.hl7.fhir.r4.model.StringType[“idElement”]->
org.hl7.fhir.r4.model.StringType[“idElement”]->org.hl7.fhir.r4.model.StringType[“idElement”]->
org.hl7.fhir.r4.model.StringType[“idElement”]->org.hl7.fhir.r4.model.StringType[“idElement”]…

2.Accepting FHIR Object as RequestBody

Following API accept RelatedPerson FHIR resource as the request body. Calling this API results in the following error:

{“timeMillis”:“1651905795382”,“thread”:“http-nio-8080-exec-2”,“level”:“WARN”,“loggerName”:

“org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver”,

“message”:“Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘application/json;charset=UTF-8’ not supported]” ,

“req_track_id”:""}

2 Likes