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,
- How to Get List of All Country Codes in Java Using Locale Class
- Unsupported major.minor version 52.0 in java
- Java - How to set custom thread name?
- Get the current timestamp in Java
- Java Spring Boot 3 Web Hello World with Gradle in IntelliJ
- [fix] NullPointerException Cannot Invoke findById because Repository is null - Java Spring
- java: unclosed string literal [Error]
- Convert Java Byte Array to String with code examples
- Error: Can not find the tag library descriptor for
- Java 8 - Convert List to Map Examples
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds
- Fix java.net.ProtocolException: Invalid HTTP method
- Java: Convert Stream to List
- Java equals method - Tutorial
- List of Java JDBC Database Driver Jars, Classes and URLs Details
- Read YAML file Java Jackson Library
- How to display Java Date Time timezone GMT/UTC offset using SimpleDateFormat
- List of Java Keywords
- Enable JSON Pretty Print in Java Jackson
- How to Word-Warp Console logs in IntelliJ
- Convert Map to List in Java 8 using Stream API
- Create a Directory using Java Code
- Ways to Convert Integer or int to Long in Java
- [Program] How to read three different values using Scanner in Java
- Java JDBC Example with Oracle Database Driver Connection
More Posts:
- [Fix] Cannot connect to Microsoft SQL Server, Error: 18456 - Microsoft
- How to know list of images available on your device - Docker
- What is Carbon Lang (successor to C++?) experimental Language by Google - News
- How to Change Text Size for Android ActionBar - Android
- Git Commit - Author identity unknown, Please tell me who you are email - Git
- macOS Big Sur compatible Macs List - MacOS
- Programmatically check if Facebook is installed on Android device - Android
- Telegram down in Europe - users facing connection issues and 500 Internal Server error - News