Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void post_example() throws IOException
- {
- CloseableHttpClient client = HttpClients.createDefault();
- HttpPost post = new HttpPost("http://httpbin.org/post");
- ArrayList<NameValuePair> params = new ArrayList<>();
- params.add(new BasicNameValuePair("param-1", "12345"));
- params.add(new BasicNameValuePair("param-2", "Hello!"));
- post.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
- HttpResponse response = client.execute(post);
- HttpEntity entity = response.getEntity();
- entity.writeTo(System.out);
- client.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement