REST module error querying a specific location: Illegal character in query

Hi Guys,

I’m using rest to query a specific location from openmrs database. Using a java client it gives me an error but the same query works fine when using rest from within openmrs.

I know the error has to do with the space in the parameter HD Gile

Can somebody help me?


/openmrs3/ws/rest/v1/location?q=HD Gile


Exception in thread "main" java.lang.IllegalArgumentException
	at Source)
	at org.apache.http.client.methods.HttpGet.<init>(
	at cl.ciochile.victoraravena.ApiAuthRest.getRequestGet(
	at cl.ciochile.test.Test.main(
Caused by: Illegal character in query at index 55: http://localhost:8080/openmrs3/ws/rest/v1/location?q=HD Gile
	at$ Source)
	at$Parser.checkChars(Unknown Source)
	at$Parser.parseHierarchical(Unknown Source)
	at$Parser.parse(Unknown Source)
	at<init>(Unknown Source)
	... 4 more

Try escaping the query parameter to URI.

1 Like

it worked replacing the white space with &


I guess the “Gile” part is ignored because & is the parameter separator.

You should replace whitespace with “%20”.

1 Like

Thankx Luis. Your suggestion it’s the actual solution.