Stream: ibm
Topic: R4 POST /MedicationStatement 415 Response
Scott Carrier (Oct 24 2019 at 21:25):
Transitioning from DSTU2 to R4 and I'm getting a 415 response w/out a response body to the following pseudo request :
curl -X POST .../api/v4/MedicationStatement \ -H 'Accept: */*' \ -H 'Content-Type: application/json+fhir' \ -d '<MedicationStatement JSON>'
This worked w/ DSTU2, but not R4. What content type should I be using in R4?
Thanks in advance
Lee Surprenant (Oct 24 2019 at 21:58):
Hi Scott, thanks for the question. the Media type for FHIR JSON changed from application/json+fhir
to application/fhir+json
after DSTU2.
Lee Surprenant (Oct 24 2019 at 22:00):
However, I do have a related question for the rest of the team: what is the expected action if the client leaves off the Content-Type header? Is that header strictly required or can we default to application/fhir+json somehow? I guess we're sort of limited by JAX-RS?
Paul Bastide (Oct 24 2019 at 23:34):
It should map to application/json+fhir
Paul Bastide (Oct 24 2019 at 23:34):
It's in the code, that it maps in FHIRHttpRequestWrapper
Paul Bastide (Oct 24 2019 at 23:49):
Just double checked, we do this:
Paul Bastide (Oct 24 2019 at 23:49):
default:
httpResponse.setContentType(com.ibm.fhir.core.FHIRMediaType.APPLICATION_FHIR_JSON);
break;
}
Paul Bastide (Oct 24 2019 at 23:49):
when we don't find a matching contentType, we set it.
Lee Surprenant (Oct 24 2019 at 23:54):
interesting. when i tried from curl without the Content-Type header, I got back a 415. maybe curl is doing something "interesting" under the covers. will check server logs to see whats going on when i get a chance...definitely not too important though
Paul Bastide (Oct 24 2019 at 23:58):
what shows up when you add -v?
Paul Bastide (Oct 24 2019 at 23:58):
GET / HTTP/2
Host: google.com
User-Agent: curl/7.54.0
Accept: /
Paul Bastide (Oct 24 2019 at 23:58):
I get that
Paul Bastide (Oct 24 2019 at 23:59):
so I doubt it is Curl, sometimes when you go through an intermediate proxy, it'll rewrite the request. I have a doubt on that, but worth putting in the back of our minds
Paul Bastide (Oct 25 2019 at 00:00):
Oh... I see why
Paul Bastide (Oct 25 2019 at 00:00):
that's ONLY in the exception case
Paul Bastide (Oct 25 2019 at 00:00):
} catch (FHIRException e) {
Paul Bastide (Oct 25 2019 at 00:00):
on line 127
Last updated: Apr 12 2022 at 19:14 UTC