API 錯誤訊息
當 API 要求因要求錯誤或伺服器錯誤而失敗時,會以 JSON 格式傳回錯誤回應訊息。
即使端點支援其他 MIME 類型,也會以 JSON 格式傳回錯誤回應訊息。 錯誤回應訊息包括錯誤訊息本身、錯誤說明、端點的唯一錯誤碼、HTTP 回應訊息及 HTTP 回應碼。
錯誤回應包括下列欄位:
- message: 錯誤訊息
- details: 其他資訊的欄位,不一定會移入資料
- description: 特定錯誤的說明
- code: 唯一錯誤回應碼
- http_response:
- message:HTTP 回應訊息
- code:HTTP 回應狀態碼
例如,下列 API 要求會嘗試取得稱為 "test-set" 之不存在參照集的相關資訊:
https://<host_ip>/api/reference_data/sets/test_set
HTTP404會傳回回應碼及下列 JSON 錯誤回應訊息:
{
"message": "test_set does not exist",
"details": {},
"description": "The reference set does not exist.",
"code": 1002,
"http_response": {
"message": "We could not find the resource you requested.",
"code": 404
}
}
下表提供 IBM® QRadar ® REST API 所傳回 HTTP 回應錯誤種類的相關資訊:
| HTTP 錯誤種類 | HTTP 回應碼 | HTTP 回應訊息 |
|---|---|---|
| Multiple Choices | 300 | The requested resource corresponds to any one of a set of representations, each with its own specific location. |
| Moved Permanently | 301 | The resource has moved permanently. Please refer to the documentation. |
| 找到 | 302 | The resource has moved temporarily. Please refer to the documentation. |
| 請參閱其他 | 303 | The resource can be found under a different URI. |
| Not Modified | 304 | The resource is available and not modified. |
| 使用 Proxy | 305 | The requested resource must be accessed through the proxy given by the Location field. |
| 暫時重新導向 | 307 | The resource resides temporarily under a different URI. |
| 要求不正確 | 400 | Invalid syntax for this request was provided. |
| Unauthorized | 401 | You are unauthorized to access the requested resource. Please log in. |
| Forbidden | 403 | Your account is not authorized to access the requested resource. |
| 找不到 | 404 | We could not find the resource you requested. Please refer to the documentation for the list of resources. |
| Method Not Allowed | 405 | This method type is not currently supported. |
| 不接受 | 406 | Acceptance header is invalid for this endpoint resource. |
| Proxy Authentication Required | 407 | Authentication with proxy is required. |
| Request Timeout | 408 | Client did not produce a request within the time that the server was prepared to wait. |
| 衝突 | 409 | The request could not be completed due to a conflict with the current state of the resource. |
| Gone | 410 | The requested resource is no longer available and has been permanently removed. |
| 需要的長度 | 411 | Length of the content is required, please include it with the request. |
| 前置條件失敗 | 412 | The request did not match the pre-conditions of the requested resource. |
| Request Entity Too Large | 413 | The request entity is larger than the server is willing or able to process. |
| 要求 URI 太長 | 414 | The request URI is longer than the server is willing to interpret. |
| 不受支援的媒體類型 | 415 | The requested resource does not support the media type provided. |
| 無法滿足所要求的範圍 | 416 | The requested range for the resource is not available. |
| Expectation Failed | 417 | Unable to meet the expectation given in the Expect request header. |
| 遺漏引數 | 419 | The requested resource is missing required arguments. |
| 引數無效 | 420 | The requested resource does not support one or more of the given parameters. |
| 無法處理的實體 | 422 | The request was well-formed but was unable to be followed due to semantic errors. |
| 內部伺服器錯誤 | 500 | Unexpected internal server error. |
| Not Implemented | 501 | The requested resource is recognized but not implemented. |
| Bad Gateway | 502 | Invalid response received when acting as a proxy or gateway. |
| Service Unavailable | 503 | The server is currently unavailable. |
| Gateway Timeout | 504 | Did not receive a timely response from upstream server while acting as a gateway or proxy. |
| 不支援 HTTP 版本 | 505 | The HTTP protocol version used in the request message is not supported. |
| 起始設定失敗 | 550 | A failure occurred during initialization of services. API will be unavailable. |