REST API
PATCH Partial Update
RequestValidateParseMedium
What you will learn
- JSON Patch (RFC 6902) vs JSON Merge Patch (RFC 7396) produce different results โ know which the API uses
- Partial updates must not clear fields accidentally โ sending empty is not the same as sending null
- Test that unmodified fields are unchanged โ a PATCH that resets them is a full PUT in disguise
Description
Partially update a user with only changed fields. Verify only specified fields are modified.
Test Scenario
const response = await request.patch('/api/v1/users/1', {
data: { name: 'New Name' } // Only update name
});
expect(response.status()).toBe(200);Endpoint
/api/v1/users/:idTesting Tips
- โขPATCH updates only specified fields
- โขOther fields remain unchanged
- โขGood for single-field updates
// Playwright API Testing - RESTimport { test, expect } from '@playwright/test';test('REST API request', async ({ request }) => {const response = await request.get('/api/v1/resource');expect(response.ok()).toBeTruthy();expect(response.status()).toBe(200);const data = await response.json();expect(data).toBeDefined();});
Challenge ID: rest-patch-partial-update
2 frameworks available
API Playground
Send requests and inspect responses
Endpoint: /api/v1/users/:id
Press Enter to send