我正在尝试使用球衣来调用hcm休息终点
https:///resources/11.12.1.0/emps?q = FirstName喜欢'Astha'
我得到以下异常
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
所以我尝试编码网址
try {
URL = URLEncoder.encode(URL, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
但是这给了我
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)
使用'='的简单查询参数可以正常编码和所有..like / emps?q = FirstName ='Astha' 但是我想使用'like'运算符,它需要url中的空格。如何使它工作?请帮忙
我尝试使用Spaces in URLs?中讨论的%20和+替换空格。它对我不起作用。它没有给出任何结果。
这里有hcm rest end point api https://docs.oracle.com/en/cloud/saas/global-human-resources/r13-update17d/farws/Querying_a_Collection.html
有人之前使用过这个api吗?如果是,如何使用jersey从java调用以下内容?
/ resources / latest / emps?q = FirstName喜欢'Ki%'