MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
HTTP Methods Overview0%
Study Materials
REST API Development with DjangoProgress 0%
1.1REST Principles1.2HTTP Methods Overview1.3Status Codes
HomeTutorialsREST API Development with DjangoHTTP Methods Overview
Status Codes

HTTP Methods Overview

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

HTTP Methods: GET, POST, PUT, PATCH, DELETE

The HTTP protocol defines a set of request methods to indicate the desired action to be performed on a given resource. Designing professional REST APIs requires strict adherence to method semantics, idempotency, and safety.


1. HTTP Methods Comparison Matrix

MethodCRUD ActionSafe?Idempotent?Request Body Allowed?Standard Success Status
GETRead / RetrieveYesYesNo200 OK
POSTCreate / ActionNoNoYes201 Created
PUTReplace / OverwriteNoYesYes200 OK or 204 No Content
PATCHPartial UpdateNoNo (Technically)Yes200 OK
DELETEDestroy / RemoveNoYesOptional (Rare)204 No Content

2. Safe vs Idempotent Methods

  • Safe Methods: Calling the method never modifies server-side resource state. GET, HEAD, and OPTIONS are safe (read-only).
  • Idempotent Methods: Making the exact same request once produces the exact same server-side outcome as making it 100 times. GET, PUT, DELETE, HEAD, and OPTIONS are idempotent.
1Idempotence Example (PUT vs POST):
2POST /orders/ ──► Executes 5 times ──► Creates 5 separate order records! (NOT IDEMPOTENT)
3PUT /users/4/ ──► Executes 5 times ──► Replaces user 4 with identical data (IDEMPOTENT)
4DELETE /orders/9 ──► Executes 5 times ──► Order 9 is gone after run 1; remaining runs do nothing (IDEMPOTENT)

3. The PUT vs PATCH Distinction

A frequent source of API design errors is confusing PUT and PATCH:

PUT (Full Resource Replacement):

PUT replaces the entire target resource representation. Any existing fields omitted from the payload are reset to default values or set to null!

1// Original resource on server:
2// { "id": 1, "name": "Alice", "role": "admin", "bio": "Senior Architect" }
3 
4// Client sends PUT with only name:
5// PUT /users/1/ { "name": "Alicia" }
6 
7// Result on server:
8// { "id": 1, "name": "Alicia", "role": null, "bio": null } <-- Omitted fields wiped!

PATCH (Partial Modification):

PATCH applies partial delta updates. Only the provided keys are mutated; unmentioned fields remain unchanged:

1// Client sends PATCH:
2// PATCH /users/1/ { "name": "Alicia" }
3 
4// Result on server:
5// { "id": 1, "name": "Alicia", "role": "admin", "bio": "Senior Architect" } <-- Preserved!

4. Method Handling in Django REST Framework

DRF simplifies method routing in APIViews:

1from rest_framework.views import APIView
2from rest_framework.response import Response
3from rest_framework import status
4 
5class ProductAPIView(APIView):
6 def get(self, request, pk):
7 # Safe & Idempotent Read
8 return Response({"id": pk, "name": "Cloud Server"})
9 
10 def put(self, request, pk):
11 # Complete overwrite
12 return Response({"status": "Product overwritten completely"})
13 
14 def patch(self, request, pk):
15 # Partial update
16 return Response({"status": "Product attributes patched"})
17 
18 def delete(self, request, pk):
19 # Idempotent deletion
20 return Response(status=status.HTTP_204_NO_CONTENT)

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What does it mean for an HTTP method to be "idempotent"?
Question 2
What is the critical difference between PUT and PATCH?
Question 3
What standard HTTP status code should be returned upon successful creation of a resource via POST?
Question 4
Which of the following HTTP methods is considered "safe" (read-only)?
Question 5
What standard HTTP status code should a DELETE endpoint return when deletion succeeds and no response body is returned?
Next Lesson

Status Codes

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
REST PrinciplesStatus Codes

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master REST API Development with Django with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext