[CLOSED]:OSLC: How to process '|' character in HttpRequest
Hello,
I'm trying to get resources allocation info using this URI:
https://clm.local:9443/ccm/rpt/repository/apt?fields=apt/workResourceDetails/(contributor/name|assignment|startDate|endDate)
I observed that while httpClient.execute() returns valid HttpResponse for https://clm.local:9443/ccm/rpt/repository/apt?fields=apt/workResourceDetails/(contributor/name)
it returns bad response for https://clm.local:9443/ccm/rpt/repository/apt?fields=apt/workResourceDetails/(contributor/name|assignment) because I use URLEncoder.encode() in order to make safe HttpGet.
Any ideas?
-thanks in advance
I'm trying to get resources allocation info using this URI:
https://clm.local:9443/ccm/rpt/repository/apt?fields=apt/workResourceDetails/(contributor/name|assignment|startDate|endDate)
I observed that while httpClient.execute() returns valid HttpResponse for https://clm.local:9443/ccm/rpt/repository/apt?fields=apt/workResourceDetails/(contributor/name)
it returns bad response for https://clm.local:9443/ccm/rpt/repository/apt?fields=apt/workResourceDetails/(contributor/name|assignment) because I use URLEncoder.encode() in order to make safe HttpGet.
Any ideas?
-thanks in advance
Accepted answer
Timur,
I suspect you need to encode the pipe symbol as any other special symbols, if you want to use them in an URL. I used https://www.google.de/search?q=html+special+characters+pipe+symbol
and found for example http://www.tutorialspoint.com/html/html_url_encoding.htm and http://en.wikipedia.org/wiki/Vertical_bar stating pipe: 124 7c | %7c So I would try to replace the pipe with %7c.
I suspect you need to encode the pipe symbol as any other special symbols, if you want to use them in an URL. I used https://www.google.de/search?q=html+special+characters+pipe+symbol
and found for example http://www.tutorialspoint.com/html/html_url_encoding.htm and http://en.wikipedia.org/wiki/Vertical_bar stating pipe: 124 7c | %7c So I would try to replace the pipe with %7c.
Comments
Hi Ralph,
Thanks a lot for your response!
It was my mistake.
I used:
safeURL = URLEncoder.encode("https://clm.local:9443/ccm/rpt/repository/apt?fields=apt/workResourceDetails/(contributor/name|assignment)" , "UTF-8");
and it didn't work.
I tried:
safeUrl = URLEncoder.encode("|assignment|startDate|endDate)", "UTF-8");
String rootServices = server + "/rpt/repository/apt?fields=apt/workResourceDetails/(contributor/name" + safeUrl;
and it works OK.