Komunikaty o błędach interfejsu API

Jeśli żądanie API nie powiedzie się z powodu błędów żądania lub serwera, w formacie JSON zwracany jest komunikat odpowiedzi o błędzie.

Komunikat odpowiedzi o błędzie jest zwracany w formacie JSON nawet dla punktów końcowych obsługujących inne typy MIME. Komunikat o błędzie zawiera sam komunikat o błędzie, opis błędu, unikalny kod błędu dla punktu końcowego, komunikat odpowiedzi HTTP i kod odpowiedzi HTTP.

Odpowiedź na błąd obejmuje następujące pola:

  • message: komunikat o błędzie
  • details: pole zawierające dodatkowe informacje, które mogą lub nie są zapełniane
  • description: opis konkretnego błędu
  • code: unikalny kod odpowiedzi błędu
  • http_response:
    • message: komunikat odpowiedzi HTTP
    • code: kod statusu odpowiedzi HTTP

Na przykład następujące żądanie API próbuje uzyskać informacje na temat nieistniejącego zestawu odwołań, który jest nazywany "test-set":

https://<host_ip>/api/reference_data/sets/test_set

HTTP404Zwrócono kod odpowiedzi i następujący komunikat o błędzie JSON jest zwracany:

{
  "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
   }
}

Poniższa tabela zawiera więcej informacji na temat kategorii błędów odpowiedzi HTTP zwracanych przez interfejs API usług REST produktu IBM® QRadar ® :

Kategoria błędu HTTP Kod odpowiedzi HTTP Komunikat odpowiedzi HTTP
Rezultat niejednoznaczny 300 The requested resource corresponds to any one of a set of representations, each with its own specific location.
Trwale przeniesione 301 The resource has moved permanently. Please refer to the documentation.
Znaleziono 302 The resource has moved temporarily. Please refer to the documentation.
Patrz inne 303 The resource can be found under a different URI.
Nie zmodyfikowano 304 The resource is available and not modified.
Użyj proxy 305 The requested resource must be accessed through the proxy given by the Location field.
Tymczasowe przekierowanie 307 The resource resides temporarily under a different URI.
Błędne żądanie 400 Invalid syntax for this request was provided.
Nie autoryzowano 401 You are unauthorized to access the requested resource. Please log in.
Zabronione 403 Your account is not authorized to access the requested resource.
Nie znaleziono 404 We could not find the resource you requested. Please refer to the documentation for the list of resources.
Niedozwolona metoda 405 This method type is not currently supported.
Niedopuszczalne 406 Acceptance header is invalid for this endpoint resource.
Wymagane uwierzytelnianie proxy 407 Authentication with proxy is required.
Przekroczono limit czasu żądania 408 Client did not produce a request within the time that the server was prepared to wait.
Konflikt 409 The request could not be completed due to a conflict with the current state of the resource.
Brak 410 The requested resource is no longer available and has been permanently removed.
Wymagana długość 411 Length of the content is required, please include it with the request.
Nie powiodło się sprawdzanie warunku wstępnego 412 The request did not match the pre-conditions of the requested resource.
Zbyt duży obiekt żądania 413 The request entity is larger than the server is willing or able to process.
Zbyt długi identyfikator URI żądania 414 The request URI is longer than the server is willing to interpret.
Nieobsługiwany typ nośnika 415 The requested resource does not support the media type provided.
Nieodpowiedni żądany zakres 416 The requested range for the resource is not available.
Nie powiodło się sprawdzanie oczekiwanych wartości 417 Unable to meet the expectation given in the Expect request header.
BRAK ARGUMENTÓW 419 The requested resource is missing required arguments.
NIEPOPRAWNE ARGUMENTY 420 The requested resource does not support one or more of the given parameters.
JEDNOSTKA NIEPRZETWARZALNA 422 The request was well-formed but was unable to be followed due to semantic errors.
Wewnętrzny błąd serwera 500 Unexpected internal server error.
Nie zaimplementowano 501 The requested resource is recognized but not implemented.
Błędna brama 502 Invalid response received when acting as a proxy or gateway.
Niedostępna usługa 503 The server is currently unavailable.
Przekroczono limitu czasu bramy 504 Did not receive a timely response from upstream server while acting as a gateway or proxy.
Nieobsługiwana wersja protokołu HTTP 505 The HTTP protocol version used in the request message is not supported.
NIEPOWODZENIE INICJOWANIA 550 A failure occurred during initialization of services. API will be unavailable.