-
Import the API Collection (if available):
- Import the
onboarding_api_insomnia.jsonfile into Insomnia - Set the base URL environment variable to:
http://127.0.0.1:8000/api
- Import the
-
Create a New Request:
- Method:
POST - URL:
{{base_url}}/candidates/ - Headers:
Content-Type: application/json
- Method:
-
Authentication (if required):
- Add any necessary authentication headers
The candidates.json file contains 50 candidate entries formatted for the Django REST API. Each entry includes:
name: Full name of the candidateemail: Unique email addressphone: Phone number (15 chars max)age: Integer between 18-25address: Text addressskills: Comma-separated string of skillstwelfth_pass: Boolean (true for all entries)family_income: Decimal (under 3 lakh for eligibility)not_working: Boolean (true for all entries)
Method: POST
URL: http://127.0.0.1:8000/api/candidates/
Body (JSON):
{
"name": "Aarav Sharma",
"email": "aarav.sharma@example.com",
"phone": "+91-9876543210",
"age": 22,
"skills": "Python, Data Analysis",
"address": "Delhi, India",
"twelfth_pass": true,
"family_income": 250000.00,
"not_working": true
}- Copy each JSON object from
candidates.json - Paste into Insomnia request body
- Send 50 separate POST requests
Create a simple Python script to automate the process:
import requests
import json
API_URL = "http://127.0.0.1:8000/api/candidates/"
with open('candidates.json', 'r') as f:
candidates = json.load(f)
for candidate in candidates:
response = requests.post(API_URL, json=candidate)
if response.status_code == 201:
print(f"✓ Created candidate: {candidate['name']}")
else:
print(f"✗ Failed to create {candidate['name']}: {response.text}")Create a custom Django management command for bulk import.
After importing, verify the data:
- Check Count: GET
http://127.0.0.1:8000/api/candidates/should return 50 candidates - Eligibility Check: POST to
/api/candidates/{id}/validate_eligibility/for each candidate - Dashboard: Check the frontend dashboard at
http://localhost:3002(or your Next.js port)
- Age Range: 18-25 years
- Income Range: ₹2,15,000 - ₹2,95,000 (all under ₹3 lakh)
- Locations: 50 different Indian cities
- Skills: Diverse technology and domain skills
- All Eligible: All candidates meet MagicBus foundation criteria
- 400 Bad Request: Check required fields and data types
- 500 Server Error: Ensure Django server is running
- Unique Constraint: Emails must be unique
- Validation Errors: Check age (18-25) and income (< 3 lakh) constraints