Deskripsi kode kesalahan APIs sparse spatial map
Format respons
Semua respons API menggunakan format JSON terpadu. Berikut adalah contohnya:
{
"statusCode": 119,
"msg": "Parameter has errors",
"date": "2022-06-15T09:56:30.000Z",
"result": //result hanya ada saat statusCode bernilai 0; jika terjadi error, field hasil kosong
}
| Field | Type | Deskripsi |
|---|---|---|
| statusCode | integer | Kode status bisnis. 0 menunjukkan sukses, non-0 menunjukkan error |
| msg | string | Pesan |
| result | object | Konten yang dikembalikan. Saat status code 0, merespons struktur object target image; selain itu kosong |
| date | string | Waktu server |
Penting
result hanya mencakup konten respons ketika statusCode == 0. Pada status lain, result kosong
Ketika statusCode != 0, perhatikan pesan error msg
Kategori kode kesalahan
Deskripsi HTTP status code
| HTTP status code | Deskripsi |
|---|---|
| 200 | Request berhasil (mungkin berisi business error) |
| 400 | Error parameter request |
| 401 | Autentikasi APIKey gagal |
| 403 | Permission tidak cukup atau akses resource dilarang |
| 404 | Path API URL request tidak ada |
| 500 | Internal server error |
| 502 | Application exception tertangkap, kemungkinan data error |
Catatan: Business error biasanya dikembalikan melalui respons HTTP 200, dan jenis error spesifik diidentifikasi dalam field statusCode.
Daftar business status code
| Status Code | Message |
|---|---|
| 0 | Success |
| 101 | Uploaded file is empty |
| 102 | File size is too large |
| 106 | Missing parameter or parameter is empty |
| 110 | Call server API errors |
| 111 | Resource not found |
| 401 | Authentication token expired |
| 401 | Authentication parameter is missing |
| 401 | Unknown appId or appKey |
| 401 | Account is locked |
| 401 | Authentication failed, invalid signature or token |
Skenario error umum
Timeout tanpa respons
- Request Timeout: Jaringan cukup lambat. Disarankan untuk memeriksa lingkungan jaringan client
Error terkait autentikasi
- Http 401 Unauthorized: Autentikasi APIKey gagal. Periksa apakah appId/appKey benar
- Status code 401: Application key tidak valid atau application tidak ada. Periksa konfigurasi application
Error parameter
- 400 Bad Request: Format parameter request salah
Error operasi resource
- Status code 10x: Target resource yang dikueri tidak ada, atau parameter salah
Error sistem
- Http 50x Internal Server Error: Internal server exception atau application exception tertangkap. Disarankan untuk menguji di website atau dengan sample
Rekomendasi praktik terbaik
- Penanganan client: Disarankan menentukan apakah operasi bisnis berhasil berdasarkan field
statusCode, bukan hanya mengandalkan HTTP status code - Retry error: Untuk error 5xx dapat retry seperlunya. Untuk error 4xx, periksa parameter request
- Logging: Disarankan mencatat respons error lengkap agar troubleshooting lebih mudah
- Penanganan timeout: Tetapkan request timeout yang wajar untuk menghindari menunggu terlalu lama