Sending HTTP Requests using Apache HTTP Client:
Below is the sample code to test end points using Apache Http Client in Java
This is a POST Method.
package org.apache.http.examples.client; import java.io.BufferedReader; import java.io.InputStreamReader; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; public class PostLibrary { public static void main(String args[]) throws Exception { String url = "http://localhost/PublicAuthentication/"; HttpClient client = HttpClientBuilder.create().build(); HttpPost post = new HttpPost(url); // add header post.setHeader("Content-Type", "Application/JSON"); //Compose JSON post.setEntity(new StringEntity("{\"username\":\"user@acs.com\", \"password\":\"password\"}")); //post.setEntity(new UrlEncodedFormEntity(urlParameters)); HttpResponse response = client.execute(post); System.out.println("Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } System.out.println(result); } }
It’s hard to find your website in google. I found it on 17 spot, you should build quality backlinks , it will help you to get more visitors.
I know how to help you, just type in google – k2 seo tips
LikeLike