Skip to main content
REST API

404 Not Found

ErrorValidateRequestEasy

What you will learn

  • Differentiate 404 Not Found (never existed) from 410 Gone (existed, removed)
  • Test path vs query: /users/999 (path 404) vs /users?id=999 (empty 200) โ€” different semantics
  • Verify 404 doesn't leak existence โ€” avoid 403 for hidden resources if 404 is the contract

Description

Handle non-existent resource requests.

Test Scenario

const response = await request.get('/api/v1/users/99999');
expect(response.status()).toBe(404);
Endpoint/api/v1/errors/404

Testing Tips

  • โ€ขRequest non-existent ID
  • โ€ขCheck error message includes resource
  • โ€ขVerify 404 for deleted resources
// Playwright - 404 Not Found
import { test, expect } from '@playwright/test';
test('404 for non-existent resource', async ({ request }) => {
const response = await request.get('/api/v1/users/nonexistent-id');
expect(response.status()).toBe(404);
const body = await response.json();
expect(body.error.code).toBe('USER_NOT_FOUND');
});

Challenge ID: rest-error-404

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/v1/errors/404

Press Enter to send