🎯 Purpose for OutSystems Tutorial
This API completes the **CRUD** (Create, Read, **Update**, Delete) operations. It shows how to:
- Set the **REST Method** to PUT or PATCH.
- Use a **URL Parameter** (id) to specify the resource, and a **JSON Request Body** to specify the changes.
- Understand the difference between PUT (replace) and PATCH (modify), though this demo simulates both.
- Handle the common **200 OK** or **204 No Content** status codes for successful updates.
🔗 API Endpoint Details
Method:
PUT or PATCH
Endpoint URL Template:
https://api.ankitg.in/api/update-product.php?id={product_id}
Request Body:
Must be a **JSON Object** containing the fields you wish to update.
Example Request Body (to change price and stock of ID 103):
{
"price": 9.99,
"inStock": true,
"description": "On sale now! Updated description."
}
💬 Expected Responses
A. Success Response (200 OK)
Returns a success message and the full updated product object.
{
"status": "Success",
"message": "Product ID 103 updated successfully.",
"updatedProduct": {
"id": 103,
"name": "Low-Code T-Shirt",
"price": 9.99,
"inStock": true,
"description": "On sale now! Updated description.",
"lastUpdated": "2025-11-22 10:25:00"
}
}
B. Failure Response (404 Not Found)
If the ID in the URL is not found.
{
"error": "Resource not found",
"message": "Product with ID 999 not found for update."
}
💡 Important for Tutorial Video!
To show the **impact** of this API call:- In OutSystems, **read** product 103 using a **GET** (API 2). Show the current price ($19.99) and stock (False).
- Call this **PUT/PATCH** API to change the price to $9.99 and stock to True.
- **Read** product 103 again using the **GET** (API 2). Show that the price and stock have permanently changed in the API response!