Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Call oracle hcm cloud rest service with space and single quote

PriyaTBJun 19 2018

Hi,

I need to call hcm rest service https://docs.oracle.com/en/cloud/saas/global-human-resources/r13-update17d/farws/Querying_a_Collection.html  from java. Currently I am using jersey to call the rest service.
I need to call rest service like <hcm-rest-url>/resources/latest/emps?q=FirstName like 'Ki%'

the space gives

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

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)

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2018
Added on Jun 19 2018
0 comments
449 views