API 02: Get Single Product by ID

Demonstration of a REST GET request using a URL Query Parameter for input.

🎯 Purpose for OutSystems Tutorial

This API is vital for teaching **parameterized REST API consumption** in OutSystems. It shows how to:

🔗 API Endpoint Details

Method:

GET

Endpoint URL Template:

https://api.ankitg.in/api/product-detail.php?id={id}

Required Query Parameter:

Parameter Name Type Location Description
id Integer Query String The unique ID of the product to retrieve.

💬 Expected Responses

A. Success Response (200 OK) - Product Found

Returns a single **JSON Object** corresponding to the Product structure (same fields as API 01).

Example: Requesting ID 102

{
    "id": 102,
    "name": "API Integration Handbook",
    "price": 29.50,
    "inStock": true,
    "category": "Book"
}
            

B. Failure Response (404 Not Found) - ID does not exist

Returns a generic error object when the ID is valid but the product doesn't exist.

{
    "error": "Resource not found",
    "message": "Product with ID 999 was not found."
}
            

C. Failure Response (400 Bad Request) - Missing/Invalid ID

Returns an error if the id parameter is missing or not a number.

{
    "error": "Bad Request",
    "message": "Required parameter 'id' is missing or invalid. Use: /api/product-detail.php?id={product_id}"
}
            
▶️ Watch the Tutorial on Consuming Parameterized APIs!