Skip to main content
File Operations

Download JSON File

DownloadValidateEasy

Description

Download a JSON file and validate its structure using JSON Schema or manual assertions.

Test Scenario

// Playwright: Download and verify JSON
const response = await request.get('/api/v1/files/download?format=json&rows=5&type=products');

expect(response.headers()['content-type']).toContain('application/json');

const data = await response.json();
expect(Array.isArray(data)).toBe(true);
expect(data.length).toBe(5);

// Validate structure
expect(data[0]).toHaveProperty('id');
expect(data[0]).toHaveProperty('name');
expect(data[0]).toHaveProperty('price');
expect(typeof data[0].price).toBe('number');
Endpoint/api/v1/files/download?format=json&rows=5&type=products

Testing Tips

  • •Check Content-Type is application/json
  • •Parse JSON and validate structure
  • •Use JSON Schema for complex validation
  • •Test both array and object formats
// Playwright API Testing - File Operations
import { test, expect } from '@playwright/test';
test('File download', async ({ request }) => {
const response = await request.get('/api/files/download/report.pdf');
expect(response.ok()).toBeTruthy();
expect(response.headers()['content-type']).toContain('application/pdf');
const buffer = await response.body();
expect(buffer.length).toBeGreaterThan(0);
});

Challenge ID: download-json

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/v1/files/download?format=json&rows=5&type=products

Press Enter to send