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!
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap