Micetro REST API error handling - Platform - BlueCat Gateway - 24.3.3

Gateway Administration Guide

ft:locale
en-US
Product name
BlueCat Gateway
Version
24.3.3

Gateway raises the MicetroV2ErrorResponse exception when it receives an error response from the Micetro server after an API call. The error can be handled in the workflow code by catching the error.

If the request handles creation of multiple objects (such as adding new DNS records via POST /dnsRecords), you should check for errors in the response by looking for an errors attribute.

from bluecat_libraries.micetro.apiv2.exceptions import MicetroV2ErrorResponse

def example_catching_error():
    payload_record = request.get_json()
    try:
        client = g.user.micetro_api.v2
        response = client.http_post("/dnsRecords", json=payload_record)
        if response["result"].get("errors"):
            raise InternalServerError(response["result"].get("errors"))
    except MicetroV2ErrorResponse as e:
        raise InternalServerError(e.message) from e

    return response