search resources by identifier

67 views
Skip to first unread message

Andrea Caloni

unread,
Jan 14, 2022, 8:42:56 AM1/14/22
to HAPI FHIR
Hi, I have noticed that performing a search by identifier (token) for any resource on my local instance of hapi-fhir-jpaserver-starter, such as the following:

http://localhost:8090/fhir/PARTITION-A/Organization?identifier=https://github.com/synthetichealth/synthea|xyz

I get a "400 Bad Request" status.
In the server log, I found the following exception:

java.lang.IllegalArgumentException: Invalid character found in the request target [/fhir/PARTITION-A/Organization?identifier=urn:foo|7000135 ]. The valid characters are defined in RFC 7230 and RFC 3986

If I encode the | character as %7C, the request is accepted by the server.

Please note that the same query, issued to the public FHIR server UHN_HAPI Server (        http://hapi.fhir.org/baseR4), works correctly with the | character, without encoding to %7C.
Which can be the fix on the local instance ?
I am running it both within IntelliJ, as a spring boot application, both as a docker container.
It's a question of some configuration ?

Andrea Caloni

unread,
Jan 21, 2022, 6:25:36 AM1/21/22
to HAPI FHIR
I found a solution to this issue, specific to the case of deploying the JPA server to Tomcat application server.
In the Tomcat documentation I found:

The HTTP/1.1 specification requires that certain characters are %nn encoded when used in URI query strings. Unfortunately, many user agents including all the major browsers are not compliant with this specification and use these characters in unencoded form.

For this reason, it's necessary to add the 'relaxedQueryChars' attribute to server.xml configuration file.
The value may be any combination of the following characters: " < > [ \ ] ^ ` { | } .

Anybody has a more generic solution to this issue, or some additional recommendations ?
Thanks in advance
Regards
Andrea
Reply all
Reply to author
Forward
0 new messages