Skip to main content
REST API

PUT Update User

RequestValidateParseEasy

What you will learn

  • Understand PUT (full replace) vs PATCH (partial) โ€” using PUT as PATCH loses fields
  • Use conditional requests (If-Match) to prevent lost-update races in concurrent edits
  • Assert the response reflects the update โ€” don't trust the status code alone

Description

Update an existing user with full replacement. Verify all fields are updated.

Test Scenario

const response = await request.put('/api/v1/users/1', {
  data: { name: 'Updated', email: 'updated@test.com' }
});
expect(response.status()).toBe(200);
Endpoint/api/v1/users/:id

Testing Tips

  • โ€ขPUT replaces entire resource
  • โ€ขSend all required fields
  • โ€ขCheck 200 OK on success
// Playwright - PUT update user
import { test, expect } from '@playwright/test';
test('PUT /api/v1/users/:id', async ({ request }) => {
const userId = '1';
const updatedData = {
name: 'Updated Name',
email: 'updated@example.com'
};
const response = await request.put(`/api/v1/users/${userId}`, {
data: updatedData
});
expect(response.ok()).toBeTruthy();
const updated = await response.json();
expect(updated.name).toBe(updatedData.name);
expect(updated.email).toBe(updatedData.email);
});

Challenge ID: rest-put-update-user

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/v1/users/:id

Press Enter to send