Fix Invalid HTTP method Invalid HTTP method: SET
 at java.base/
 at java.base/
 at java.base/
 at HTTPExample.main(

ProtocolException invalid HTTP method occurs when you are trying to use an HTTP method that is invalid. Below is the list of valid HTTP methods that you can make use of depending upon what you are trying to achieve (usually associated with CURD at the server end),

  1. POST: Used to perform Create operation.
  2. GET: Used to peform Select operation.
  3. PUT: Used to peform Update/Replace operation.
  4. PATCH: Used to perform Update/Modify operation.
  5. DELETE: Used to perform Delete operation,
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
Java ProtocolException Invalid HTTP method
Java ProtocolException Invalid HTTP method

As you can I have used SET as the HTTP Request Method which is an invalid one!

Have Questions? Post them here!

Recent Posts:

Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.