API Single District Documentation

Retrieve Single District Request

This is a GET request to retrieve a single district by its ID. Make a request to the following endpoint:

GET /api/districts/{id}

Request Example:

The request requires the district ID in the URL path, and no request body is needed.

For example, to retrieve the district with ID 2:

GET /api/districts/2

Successful Response (Status Code: 200):


{
    "status": "success",
    "code": 200,
    "message": "District retrieved successfully",
    "data": {
        "id": 2,
        "name": "Updated District 1",
        "code": "UD1"
    }
}
                

Response Explanation:

  • status: Indicates the success or failure of the request. "success" means the district was successfully retrieved.
  • code: The HTTP status code. In this case, it’s `200`, indicating that the district was successfully retrieved.
  • message: A human-readable message about the result of the request, in this case, "District retrieved successfully".
  • data: Contains the retrieved district's information:
    • id: The unique ID of the district.
    • name: The name of the district.
    • code: The code assigned to the district.

Notes:

  • The id in the URL is required to identify which district you want to retrieve.
  • If the district with the given ID does not exist, an error response will be returned.
  • The response will include the `status`, `code`, `message`, and `data` fields, where `data` contains the district’s details.