Ad Manager API 錯誤也會包含專屬的 requestId,您可以將這項資訊提供給支援團隊,協助排解問題。以下範例會擷取
來自 GoogleAPIError 的 requestId;
except GoogleAPIError as e:
requestInfoType = "type.googleapis.com/google.rpc.RequestInfo"
requestInfo = [detail for detail in e.details if detail['@type'] == requestInfoType][0]
print(requestInfo['requestId'])
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-09-11 (世界標準時間)。"],[[["Google provides a Python client library, `google-ads-admanager`, for seamless interactions with the Ad Manager API, installable via pip."],["The client library utilizes Application Default Credentials (ADC) for authentication, prioritizing environment variables, gcloud CLI, and Google Cloud resource service accounts."],["Developers can make requests to various Ad Manager services using synchronous or asynchronous methods provided by service-specific client objects."],["Error handling is facilitated through the `GoogleAPIError` base class and its `reason` field, enabling developers to identify and manage issues effectively."],["Proxy settings can be configured using the `http_proxy` and `https_proxy` environment variables, allowing customization of network communication."]]],["The content outlines using Google's Python client library for the Ad Manager API. Key actions include installing the `google-ads-admanager` library via PyPI and configuring credentials using OAuth2 and Application Default Credentials (ADC), with environment variables, the Google Cloud CLI, or service accounts. A request is made to read a network, demonstrating synchronous method usage. Error handling is shown using `GoogleAPIError` to get `requestId` and using `e.reason`. It details configuring the proxy settings for the library via `http_proxy` and `https_proxy`.\n"]]