REST API
POST Create Order
RequestParseValidateMedium
What you will learn
- Orders are the canonical non-idempotent POST โ always pair with an Idempotency-Key for retry safety
- Test concurrent orders from the same user โ depends on inventory availability; race-window bugs hide here
- Assert 201 Created + Location header pointing at the new resource โ clients follow Location, not body IDs
Description
Create an order with nested items. Validate complex request body structure.
Test Scenario
const response = await request.post('/api/v1/orders', {
data: {
userId: 1,
items: [{ productId: 1, quantity: 2 }]
}
});
expect(response.status()).toBe(201);Endpoint
/api/v1/ordersTesting Tips
- โขSend nested array of items
- โขValidate total calculation
- โขCheck created order has ID
// 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-post-create-order
2 frameworks available
API Playground
Send requests and inspect responses
Endpoint: /api/v1/orders
Press Enter to send