Hackforge Academy

Category: java

PUT vs PATCH HTTP Methods

Published on 24 Feb 2026

Explanation


PUT method is used to completely
update a resource.

Code:

fetch('/users/1', {
  method: 'PUT',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ name: 'Updated Name' })
});

Explanation


PATCH method is used to partially update a resource.

Code:

fetch('/users/1', {
  method: 'PATCH',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ email: 'new@mail.com' })
});

Explanation


PUT replaces entire resource,
missing fields may be removed.

Code:

// PUT replaces full object

Explanation


PATCH modifies only specified fields.

Code:

// PATCH updates only provided fields

Explanation


Both PUT and PATCH are idempotent
if used correctly.

Code:

// Multiple identical PUT calls result in same resource state

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community