java.net.ProtocolException: Invalid HTTP method: SET
at java.base/java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:487)
at java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:570)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:370)
at HTTPExample.main(HTTPExample.java:21)
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),
- POST: Used to perform Create operation.
- GET: Used to peform Select operation.
- PUT: Used to peform Update/Replace operation.
- PATCH: Used to perform Update/Modify operation.
- DELETE: Used to perform Delete operation,
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("SET");

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!
More Posts related to Java,
- [Fix] java.time.zone.ZoneRulesException: Unknown time-zone ID
- Parse XML file in Java using DOM Parser
- Java equals method - Tutorial
- [Program] How to read three different values using Scanner in Java
- Java: The value of the local variable string is not used
- Display Output in Java Console as a Table
- How to detect Operating System using Java code
- Java 8 Streams map() with examples
- [Fix] java: incompatible types: incompatible parameter types in lambda expression error
- Add newline character Java code example (\r \n \r\n)
- List of Java Major Minor Version Numbers
- IntelliJ Keyboard Shortcut to remove unused imports [Java]
- Java - Check if array contains the value
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- How to declare and initialize Array in Java Programming
- [Solved] com.sun.xml.ws.transport.http.servlet.WSServletContextListener ClassNotFoundException
- XmlRpcException ConnectException connection refused error
- Create a Zip file using Java Code programmatically
- List of jar files for Jax-ws (SOAP) based Java Web Services
- How to fix Java HTTP java.net.UnknownHostException
- List of jars required for Struts2 project
- [fix] java: incompatible types: double cannot be converted to java.lang.Integer Generics
- Maven BUILD FAILURE: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
- Get the current timestamp in Java
- java: unclosed string literal [Error]
More Posts:
- How to create a SharePoint list from an existing list with same columns, views, formatting, data - SharePoint
- Sign in as different user missing in SharePoint 2013, how to enable - SharePoint
- SharePoint An unexpected error has occurred - Correlation ID and PowerShell Merge-SPlogfile - SharePoint
- How to change SharePoint Online site collection or subsite URL address - SharePoint
- Failed to load resource: net::ERR_CACHE_MISS PHP - PHP
- How to install Java 11 on Mac - Java
- Calculate Volume of Sphere - C-Program
- How to check installed Tomcat version - Tomcat