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,
- Java equals method - Tutorial
- Unbound classpath container: JRE System Library [JavaSE-1.7]
- Spring Boot: @RequestBody not applicable to method
- Java 8: Steam map with Code Examples
- Java Program: Random Number Generator
- Java java.time.Clock class code examples [Java Date Time API]
- Fix: type argument is not within bounds of type-variable T
- [Fix] java.net.MalformedURLException: unknown protocol
- Java 7 addSuppression() and getSuppression() Exception Handling
- Convert Java Array to ArrayList Code Example
- How to Word-Warp Console logs in IntelliJ
- Ways Compare Dates in Java Programming with Examples
- Remove Trailing zeros BigDecimal Java
- CRUD operations in Spring Boot + JDBC
- [Java Threads] Should we extend Thread Class or implement Runnable interface
- Json Serialization and Deserialization using Java Jackson
- Create simple struts2 project using maven commands
- How to install Java OpenJDK 11 on Alpine Linux
- Unsupported major.minor version 52.0 in java
- Error: Can not find the tag library descriptor for
- Java: Convert String to Binary
- How to run Java Unit Test cases with Apache Maven?
- Java: Testing Private Methods in JUnit using reflection API Example
- Java JDBC Connection with MySQL Driver in VS Code + Troubleshooting
- Java Join Strings with Comma Separator
More Posts:
- [Solution] Java JDBC SQLException: No value specified for parameter 1 - Java
- Powershell Comments Examples - Powershell
- How to write hello world different languages syntax - HowTos
- How to Install Python Modules in VS Code - Python
- What does has notifications silenced in Messages App mean in iPhone - iOS
- How to know the version of Teams installed - Teams
- Get the Current Working Directory using Java Code - Java
- Get the Complete Sha256 Container ID for Docker Run Command - Docker