Skip to main content

How to Create Appropriate API error messages

When an API request fails due to request errors or server errors, an error response message is returned in JSON format.

An error response message is returned in JSON format even for endpoints that support other MIME types. The error response message includes error message itself, a description of the error, a unique error code for the endpoint, an HTTP response message, and an HTTP response code.
The error response includes following fields:
  • message: the error message
  • details: a field for additional information, which may or may not be populated
  • description: description of the specific error
  • code: Unique error response code
  • http_response:
    • message: HTTP response message
    • code: HTTP response status code
For example, the following API request attempts to get information about a non-existent reference set that is called “test-set”
https://<host_ip>/api/reference_data/sets/test_set
An HTTP 404 response code and the following JSON error response message are returned:
{
  "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
   }
}
The following table provides more information about the HTTP response error categories returned by the IBM® Security QRadar® REST API:

HTTP error category HTTP response Code HTTP response message
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.
FOUND 302 The resource has moved temporarily. Please refer to the documentation.
SEE OTHER 303 The resource can be found under a different URI.
NOT MODIFIED 304 The resource is available and not modified.
USE PROXY 305 The requested resource must be accessed through the proxy given by the Location field.
TEMPORARY REDIRECT 307 The resource resides temporarily under a different URI.
BAD REQUEST 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.
NOT FOUND 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.
NOT ACCEPTABLE 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.
CONFLICT 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.
LENGTH REQUIRED 411 Length of the content is required, please include it with the request.
PRECONDITION FAILED 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.
REQUEST-URI TOO LONG 414 The request URI is longer than the server is willing to interpret.
UNSUPPORTED MEDIA TYPE 415 The requested resource does not support the media type provided.
REQUESTED RANGE NOT SATISFIABLE 416 The requested range for the resource is not available.
EXPECTATION FAILED 417 Unable to meet the expectation given in the Expect request header.
MISSING ARGUMENTS 419 The requested resource is missing required arguments.
INVALID ARGUMENTS 420 The requested resource does not support one or more of the given parameters.
UNPROCESSABLE ENTITY 422 The request was well-formed but was unable to be followed due to semantic errors.
INTERNAL SERVER ERROR 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 VERSION NOT SUPPORTED 505 The HTTP protocol version used in the request message is not supported.
INITIALIZATION FAILURE 550 A failure occurred during initialization of services. API will be unavailable.

Popular posts from this blog

How to read or extract text data from passport using python utility.

Hi ,  Lets get start with some utility which can be really helpful in extracting the text data from passport documents which can be images, pdf.  So instead of jumping to code directly lets understand the MRZ, & how it works basically. MRZ Parser :                 A machine-readable passport (MRP) is a machine-readable travel document (MRTD) with the data on the identity page encoded in optical character recognition format Most travel passports worldwide are MRPs.  It can have 2 lines or 3 lines of machine-readable data. This method allows to process MRZ written in accordance with ICAO Document 9303 (endorsed by the International Organization for Standardization and the International Electrotechnical Commission as ISO/IEC 7501-1)). Some applications will need to be able to scan such data of someway, so one of the easiest methods is to recognize it from an image file. I 'll show you how to retrieve the MRZ information from a picture of a passport using the PassportE

How to generate class diagrams pictures in a Django/Open-edX project from console

A class diagram in the Unified Modeling Language ( UML ) is a type of static structure diagram that describes the structure of a system by showing the system’s classes, their attributes, operations (or methods), and the relationships among objects. https://github.com/django-extensions/django-extensions Step 1:   Install django extensions Command:  pip install django-extensions Step 2:  Add to installed apps INSTALLED_APPS = ( ... 'django_extensions' , ... ) Step 3:  Install diagrams generators You have to choose between two diagram generators: Graphviz or Dotplus before using the command or you will get: python manage.py graph_models -a -o myapp_models.png Note:  I prefer to use   pydotplus   as it easier to install than Graphviz and its dependencies so we use   pip install pydotplus . Command:  pip install pydotplus Step 4:  Generate diagrams Now we have everything installed and ready to generate diagrams using the comm

Python questions and answers part 3

Q1).What is Python? Ans1:   Python  is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. It uses English keywords frequently where as other languages use punctuation, and it h as fewer syntactical constructions than other languages. Q2).Name some of the features of Python. Ans2:  Following are some of the salient features of  python It supports functional and structured programming methods as well as OOP. It can be used as a scripting language or can be compiled to byte-code for building large applications. It provides very high-level dynamic data types and supports dynamic type checking. It supports automatic garbage collection. It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java. Q3).Do you have any personal projects? Really? Ans3: This shows that you are willing to do more than the bare minimum in terms of keeping your skillset up to date. If you work on personal projects and