Hi I saw an example on StackOverflow which had this code:
String encoding = Base64Encoder.encode ("test1:test1");
HttpPost httppost = new HttpPost("http://host:post/test/login");
httppost.setHeader("Authorization", "Basic " + encoding);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
I have a task similar to this. I tried to use the same code but I couldn’t find the Base64Encoder class anywhere. Im using httpclient-4.1.2.jar and httpcore-4.1.2.jar. Can someone help me with this?
I think you need to have commons codec also to use Base64 encoding with HttpClient. Here is link. Commons codec link