Java HttpClient PUT request example

In this tutorial we will continue providing examples of how to use Apache HttpClient, in this post we will concentrate on how to make a HttpClient PUT request. Please also take time to visit our other recent posts relating to how to make a GET and POST request using HttpClient.


In order to use the HttpClient you will need to include the following dependancy

HttpClient PUT request example

In the following example (very similar to our other recent posts) we are using the HttpClient to make a HTTP PUT request, it shows how to:

  • Make a PUT request (with headers)
  • Handling the response object
  • Inspecting the status code


Running the above code sample produces the following output

In conclusion I hope this post has given you a basic understanding of how to make a HTTP PUT request using the apache HttpClient library. Please also visit our other post on how to make other HTTP requests with apache HttpClient.

Similar posts

  1. HttpClient GET request example
  2. Java HttpClient POST request example
  3. How to generate a random number in Java
  4. Java 8 Streams flatmap example
  5. How to convert JSON to Java object


  1. HttpClient Documentation

Leave a Reply