0 Replies Latest reply on Jun 19, 2018 7:07 AM by PriyaTB

    Call oracle hcm cloud rest service with space and single quote

    PriyaTB

      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)