Stream: hapi
Topic: Content-Type for extended operations
Christopher Schuler (Sep 19 2017 at 02:18):
I am experiencing some strange behavior when calling extended operations in HAPI 2.4.
The following works:
Parameters inParams = new Parameters(); inParams.addParameter().setName("patient").setValue(new StringType("Patient-12214")); inParams.addParameter().setName("startPeriod").setValue(new DateType("2001-01-01")); inParams.addParameter().setName("endPeriod").setValue(new DateType("2015-03-01")); Parameters outParams = ourClient .operation() .onInstance(new IdDt("Measure", "col")) .named("$evaluate") .withParameters(inParams) .useHttpGet() .execute();
But this does not:
Parameters inParams = new Parameters(); inParams.addParameter().setName("patient").setValue(new StringType("Patient-12214")); Parameters outParams = ourClient .operation() .onInstance(new IdDt("PlanDefinition", "apply-example")) .named("$apply") .withParameters(inParams) .useHttpGet() .execute();
I get the following error:
ca.uhn.fhir.rest.server.exceptions.InvalidRequestException: HTTP 400 Bad Request: No Content-Type header was provided in the request. This is required for "EXTENDED_OPERATION_INSTANCE" operation at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException.newInstance(BaseServerResponseException.java:306) at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:290) at ca.uhn.fhir.rest.client.GenericClient$BaseClientExecutable.invoke(GenericClient.java:741) at ca.uhn.fhir.rest.client.GenericClient$OperationInternal.execute(GenericClient.java:1630) at org.opencds.cqf.RulerTestBase.PlanDefinitionApplyTest(RulerTestBase.java:206)
So, I tried using Postman with the following request with the Content-Type set to application/json:
http://localhost:8080/cqf-ruler/baseDstu3/PlanDefinition/apply-example/$apply?patient=Patient-12214
That request generates the following error:
"issue": [ { "severity": "error", "code": "processing", "diagnostics": "Failed to parse request body as JSON resource. Error was: Failed to parse JSON content, error was: Did not find any content to parse" } ]
Am I doing something wrong or is this a known issue?
Joel Schneider (Sep 19 2017 at 14:40):
Using Postman, you could try sending a POST
request to http://localhost:8080/cqf-ruler/baseDstu3/PlanDefinition/$apply
with a body something like the following.
{ "resourceType" : "Parameters", "parameter" : [ { "name" : "patient", "valueReference" : { "identifier": { "system": "http://my-patient-id-system", "value": "Patient-12214" } } }, { "name" : "encounter", "valueReference" : { "refererence": "/Encounter/123" } }, { "name" : "practitioner", "valueReference" : { "refererence": "/Practitioner/456" } }, { "name" : "organization", "valueReference" : { "refererence": "/Organization/789" } } ] }
Not sure if that helps, but it should at least cause the server to return a different error message.
Christopher Schuler (Sep 19 2017 at 19:05):
Thanks @Joel Schneider, that helped. I broke up the Parameter resource param into separate optional params and all is well. Makes sense that the request would need to be a POST with a resource param.
Last updated: Apr 12 2022 at 19:14 UTC