REST API Reference

Note: This page is for your reference only. It is not part of the official assignment requirements, but may help you complete your work more easily.

🧭 Available Endpoints

Method Endpoint Description Example
GET /teach/users Get a list of all users /teach/users
GET /teach/users/{id} Get user details by ID /teach/users/43
PUT /teach/users/{id} Update user address info /teach/users/43
POST /teach/users/{id}/upload-image Upload profile image /teach/users/43/upload-image
GET /teach/users/{id}/audit Get audit log for user /teach/users/43/audit

💡 Example JavaScript fetch() Calls

// GET all users
fetch('https://mx.velodata.org/api/v2/teach/users')
  .then(res => res.json())
  .then(data => console.log(data));

// GET user by ID
fetch('https://mx.velodata.org/api/v2/teach/users/43')
  .then(res => res.json())
  .then(data => console.log(data));

// PUT update address
fetch('https://mx.velodata.org/api/v2/teach/users/43', {
  method: 'PUT',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    address_1: '123 Main St',
    address_2: 'Unit 5',
    address_3: '',
    city: 'Melbourne',
    state: 'VIC',
    postcode: '3000'
  })
})
.then(res => res.json())
.then(data => console.log(data));

// POST image upload
const formData = new FormData();
formData.append('attachment', fileInput.files[0]);

fetch('https://mx.velodata.org/api/v2/teach/users/43/upload-image', {
  method: 'POST',
  body: formData
})
.then(res => res.json())
.then(data => console.log(data));

📦 Example Request Payload (PUT)

{
  "address_1": "123 Main St",
  "address_2": "Unit 5",
  "address_3": "",
  "city": "Melbourne",
  "state": "VIC",
  "postcode": "3000"
}