Reputation: 28110
I'm using the HAPI-FHIR library's generic RESTful client to communicate with a FHIR server which is occasionally delivering some unclean XML, but the errors can be avoided if I use JSON.
This is easy to override in client.search()
by adding .encodedJson()
to the fluent chain (as mentioned on the documentation intro page). However, some methods (e.g. client.read(...)
) don't seem to have any way to set the encoding, so they accept whatever the server sends by default.
Is there perhaps a way to set a default encoding in the context or client creation so it applies wherever they are used?
Upvotes: 3
Views: 793
Reputation: 701
You know what? The fluent client has a method to set a default encoding (and pretty print behaviour for that matter) but it doesn't expose it. Weird. I'll make sure we fix that for the next version of HAPI FHIR.
In the meantime, the following workaround should set this:
((BaseClient)client).setEncoding(EncodingEnum.JSON);
Upvotes: 3