Greške
API koristi standardne HTTP statusne kodove i RFC 7807 Problem Details za odgovore s greškama.
Format greške #
Svi odgovori s greškama prate RFC 7807 Problem Details format s Content-Type: application/problem+json:
json
{
"status": 400,
"title": "Bad Request",
"detail": "The FirstName field is required."
} Statusni kodovi #
API koristi sljedeće HTTP statusne kodove:
| Status | Description |
|---|---|
| 200 OK | Zahtjev uspješan |
| 201 Created | Resurs uspješno kreiran |
| 204 No Content | Zahtjev uspješan, bez sadržaja (npr. brisanje) |
| 400 Bad Request | Nevažeći zahtjev — nedostajući ili nevažeći parametri |
| 401 Unauthorized | Autentifikacija neuspješna — nedostajući ili nevažeći API ključ |
| 403 Forbidden | Zabranjeno — API ključ nema dozvolu za ovu akciju |
| 404 Not Found | Resurs nije pronađen |
| 409 Conflict | Konflikt — zahtjev je u sukobu s postojećim podacima |
| 429 Too Many Requests | Prekoračeno ograničenje broja zahtjeva |
| 500 Internal Server Error | Interna greška servera |
Primjeri grešaka #
Greška validacije (400)
json
{
"status": 400,
"title": "Bad Request",
"detail": "The FirstName field is required."
} Nije pronađeno (404)
json
{
"status": 404,
"title": "Not Found",
"detail": "Firefighter with ID '3fa85f64-5717-4562-b3fc-2c963f66afa6' was not found."
} Konflikt (409)
json
{
"status": 409,
"title": "Conflict",
"detail": "A firefighter with this email already exists."
}