📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
✅ Some premium posts are free to read — no account needed. Follow me on Medium to stay updated and support my writing.
🎓 Top 10 Udemy Courses (Huge Discount): Explore My Udemy Courses — Learn through real-time, project-based development.
▶️ Subscribe to My YouTube Channel (172K+ subscribers): Java Guides on YouTube
Maven Dependency
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.9.0</version>
</dependency>
OkHttp DELETE Request Java Example
package com.javaguides.okhttp.tutorial.crud;
import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class OkHttpDelete {
OkHttpClient client = new OkHttpClient();
public String run(String url) throws IOException {
Request request = new Request.Builder().url(url).delete().build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
public static void main(String[] args) throws IOException {
OkHttpDelete example = new OkHttpDelete();
String response = example.run("http://localhost:8080/api/v1/employees/1");
System.out.println(response);
}
}
Comments
Post a Comment
Leave Comment