Issue in Calling webservice with special character in hostname using HTTP GET method,
When i execute it using
java code i am getting 401 unauthorized. But the same is working successfully in postman
Below is the code
String appKey = "b980cf5d9fcce29da2c51afe73334349696cb7c031434348e";
String column = URLEncoder.encode(":", "UTF-8");
String atsymbol = URLEncoder.encode("@", "UTF-8");
String url = "https://"+appKey+column+"X"+atsymbol+"app.listen360.com/organizations/628956/reviews.xml";
GetMethod httpget = new GetMethod(url);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new NameValuePair("per_page", "20"));
nvps.add(new NameValuePair("order", "asc"));
httpget.setQueryString(nvps.toArray(new NameValuePair[nvps.size()]));
HttpClient httpclient = new HttpClient();
try {
httpclient.executeMethod(httpget);
if (httpget.getStatusLine().getStatusCode() == 200) {
String responseJson = httpget.getResponseBodyAsString();
System.out.println(responseJson);
}
} catch (IOException e) {
//logError(e);
}