BAMV2ErrorResponse class - BlueCat Python Library - 23.1

BlueCat Python Library Guide

Locale
English
Product name
BlueCat Python Library
Version
23.1

Click a link to jump to the indicated section.

class bluecat_libraries.address_manager.apiv2.BAMV2ErrorResponse(message, response, status, reason, code)

Bases: bluecat_libraries.http_client.exceptions.ErrorResponse

This exception is raised when an error response is received from a target. The HTTP response is available via the response instance member.

Parameters Description
message (str)

Description of API error code.

response (Response)

The HTTP response resulting from a request.

status (int)

HTTP status code of error (400-599).

reason (str)

Reason phrase of status code.

code (str)

API error code.

Example:

from bluecat_libraries.address_manager.apiv2 import Client, BAMV2ErrorResponse

with Client(<bam_host_url>) as client:
    try:
        # This will fail because the authentication is missing.
        response = client.http_get("/configurations")
    except BAMV2ErrorResponse as exc:
        print(exc.message)
        print(exc.status)
        print(exc.reason)
        print(exc.code)

>>> The request authorization credentials are either missing or invalid
>>> 401
>>> Unauthorized
>>> InvalidAuthorizationCredentials