i am trying to call a hcm rest end point using jersey
https:///resources/11.12.1.0/emps?q=FirstName like 'Astha'
I get the below exception
Exception in thread "main" java.lang.IllegalArgumentException
at java.net.URI.create(URI.java:842)
at com.sun.jersey.api.client.Client.resource(Client.java:434)
..
Caused by: java.net.URISyntaxException: Illegal character in query at index 93: https://<my-hcm-url>/resources/11.12.1.0/emps?q=FirstName like 'Astha'
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.checkChars(URI.java:2982)
at java.net.URI$Parser.parseHierarchical(URI.java:3072)
at java.net.URI$Parser.parse(URI.java:3014)
at java.net.URI.<init>(URI.java:578)
at java.net.URI.create(URI.java:840)
... 3 more
So I tried encoding the url
try {
URL = URLEncoder.encode(URL, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
But this gives me
Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: java.lang.IllegalArgumentException: URI is not absolute
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155)
at com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:105)
at com.sun.jersey.api.client.Client.handle(Client.java:652)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
at com.sun.jersey.api.client.WebResource.get(WebResource.java:193)
......
Caused by: java.lang.IllegalArgumentException: URI is not absolute
at java.net.URI.toURL(URI.java:1080)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:163)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:153)
Simple query parameters with '=' works fine withour encoding and all ..like /emps?q=FirstName='Astha' But I want to use 'like' operator which requires space in the url. How to make it work ? Please help
I tried replacing the space with %20 and + as discussed in the Spaces in URLs?. It did not work for me. It does not give any result.
The hcm rest end point api is available here https://docs.oracle.com/en/cloud/saas/global-human-resources/r13-update17d/farws/Querying_a_Collection.html
Has anybody used this api earlier? If yes, how to call the below from java using jersey?
/resources/latest/emps?q=FirstName like 'Ki%'
WebResource resource = c.resource(ENDPOINT_URL); String response = resource.queryParams(queryParams).header("REST-Framework-Version",3).get(String.class);
– Priya Darsini Aug 02 '18 at 08:18